You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@kruton the new socket won't have a FileDescriptor, so I would think it should make things simpler, no? Or is something else trying to access the underlying file?
Maybe it won't matter since you're basically going to be only reading from the wrapped Socket's InputStream. However, this may be a performance regression because you'd have to make at least one more copy now. One to get data from the OS copied to the underlying Socket buffer and then another one to copy the received data into BoringSSL.
Android needs the socket implementation to support renegotiation (which has no tests, so you need to fix that first... which will needs someone with TLS expertise and a lot of time to test, see #228 ). The engine implementation does not support renegotiation. Merely adding renegotiation support to the engine implementation will also take someone with a even more TLS expertise. (BoringSSL tightly limits renegotiation for security reasons and you all will need to think hard about how it is exposed via engine as a result of those.)
I don't think you'll be able to do this for 1.0.0 if you want that done soon.
Once this change is completed, will it then be possible to count the number of bytes used by the SSLSocket? Seems the OpenSSL implementation does a JNI call so there is no way to capture the number of bytes written/read to the underlying socket.
@nmittler I think I've done just that. Is this what you mean? I created a DelegatingSocket class that extends Socket. All methods get delegated except getInputStream() and getOutputStream(). These get wrapped so the bytes get counted. But this will only work if the SSLSocket writes to the underlying Socket input/output streams.
But this will only work if the SSLSocket writes to the underlying Socket input/output streams.
The engine-based socket currently uses the underlying socket's streams directly. I had explored writing to a channel (if the underlying socket has one), but the performance improvement seemed relatively minor and not worth the added complexity. Even if we were using channels, your delegation pattern could account for that as well.
I'm assuming that you are currently using the FD-based socket? What is your byte-counting strategy for that?
The engine-based socket currently uses the underlying socket's streams directly.
Gotcha, thanks. I believe that answers my question (assuming you don't change the implementation.)
I'm assuming that you are currently using the FD-based socket? What is your byte-counting strategy for that?
I'm stuck 'cause it's making JNI calls. The only other idea I had was to use an SSLEngine and do everything manually. I'm nervous though, I don't want to screw up security! And I've read it wasn't given much love in earlier versions of Android.
@dave-r12 ah ok, makes sense. Yeah, the engine-based socket should make things easier for you then, since there's no black magic involved (e.g. writing to the FD directly via JNI).
If for some reason you decide to use Conscrypt's SSLEngine directly, it should handle all of the security concerns for you ... after all, that's its job :)
@nmittler It's still something I'd like to do but other things have been above it on the priority list. The main blocker is #433, which I haven't been able to make progress on diagnosing yet.
Activity
kruton commentedon Jan 26, 2017
I briefly looked at this a while ago. There seem to be a lot of fiddly interaction with
FileDescriptorinstances to make sockets work correctly.nmittler commentedon Jan 26, 2017
@kruton the new socket won't have a
FileDescriptor, so I would think it should make things simpler, no? Or is something else trying to access the underlying file?kruton commentedon Jan 26, 2017
Maybe it won't matter since you're basically going to be only reading from the wrapped
Socket'sInputStream. However, this may be a performance regression because you'd have to make at least one more copy now. One to get data from the OS copied to the underlyingSocketbuffer and then another one to copy the received data into BoringSSL.nmittler commentedon Jan 26, 2017
@kruton Agreed ... we need to benchmark the new socket on android to confirm there is no performance regression (#10)
nmittler commentedon May 24, 2017
Re-targeting for
1.0.0. We need this to properly handle closures of the underlying FD.1 remaining item
nmittler commentedon Aug 17, 2017
@flooey can we throw the flag and make this the default? It would be good to make the switch before 1.0.0 if possible.
davidben commentedon Aug 17, 2017
Android needs the socket implementation to support renegotiation (which has no tests, so you need to fix that first... which will needs someone with TLS expertise and a lot of time to test, see #228 ). The engine implementation does not support renegotiation. Merely adding renegotiation support to the engine implementation will also take someone with a even more TLS expertise. (BoringSSL tightly limits renegotiation for security reasons and you all will need to think hard about how it is exposed via engine as a result of those.)
I don't think you'll be able to do this for 1.0.0 if you want that done soon.
[Edit: fixed bug number]
Switch default to engine-based socket
nmittler commentedon Aug 17, 2017
@davidben ok thanks, I guess we'll punt on this for now then.
dave-r12 commentedon Aug 22, 2017
Once this change is completed, will it then be possible to count the number of bytes used by the
SSLSocket? Seems the OpenSSL implementation does a JNI call so there is no way to capture the number of bytes written/read to the underlying socket.nmittler commentedon Aug 22, 2017
@dave-r12 could you just use a delegate socket that counts the bytes written?
dave-r12 commentedon Aug 22, 2017
@nmittler I think I've done just that. Is this what you mean? I created a
DelegatingSocketclass that extends Socket. All methods get delegated exceptgetInputStream()andgetOutputStream(). These get wrapped so the bytes get counted. But this will only work if theSSLSocketwrites to the underlying Socket input/output streams.nmittler commentedon Aug 22, 2017
@dave-r12 yeah that's right.
The engine-based socket currently uses the underlying socket's streams directly. I had explored writing to a channel (if the underlying socket has one), but the performance improvement seemed relatively minor and not worth the added complexity. Even if we were using channels, your delegation pattern could account for that as well.
I'm assuming that you are currently using the FD-based socket? What is your byte-counting strategy for that?
dave-r12 commentedon Aug 22, 2017
Gotcha, thanks. I believe that answers my question (assuming you don't change the implementation.)
I'm stuck 'cause it's making JNI calls. The only other idea I had was to use an
SSLEngineand do everything manually. I'm nervous though, I don't want to screw up security! And I've read it wasn't given much love in earlier versions of Android.nmittler commentedon Aug 22, 2017
@dave-r12 ah ok, makes sense. Yeah, the engine-based socket should make things easier for you then, since there's no black magic involved (e.g. writing to the FD directly via JNI).
If for some reason you decide to use Conscrypt's
SSLEnginedirectly, it should handle all of the security concerns for you ... after all, that's its job :)nmittler commentedon Sep 9, 2018
@flooey is this still on the radar? It would be good to have a single socke impl.
flooey commentedon Sep 10, 2018
@nmittler It's still something I'd like to do but other things have been above it on the priority list. The main blocker is #433, which I haven't been able to make progress on diagnosing yet.