Code Monkey home page Code Monkey logo

Comments (16)

nmittler avatar nmittler commented on August 26, 2024 1

@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 :)

from conscrypt.

kruton avatar kruton commented on August 26, 2024

I briefly looked at this a while ago. There seem to be a lot of fiddly interaction with FileDescriptor instances to make sockets work correctly.

from conscrypt.

nmittler avatar nmittler commented on August 26, 2024

@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?

from conscrypt.

kruton avatar kruton commented on August 26, 2024

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.

from conscrypt.

nmittler avatar nmittler commented on August 26, 2024

@kruton Agreed ... we need to benchmark the new socket on android to confirm there is no performance regression (#10)

from conscrypt.

nmittler avatar nmittler commented on August 26, 2024

Re-targeting for 1.0.0. We need this to properly handle closures of the underlying FD.

from conscrypt.

nmittler avatar nmittler commented on August 26, 2024

@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.

from conscrypt.

davidben avatar davidben commented on August 26, 2024

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]

from conscrypt.

nmittler avatar nmittler commented on August 26, 2024

@davidben ok thanks, I guess we'll punt on this for now then.

from conscrypt.

dave-r12 avatar dave-r12 commented on August 26, 2024

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.

from conscrypt.

nmittler avatar nmittler commented on August 26, 2024

@dave-r12 could you just use a delegate socket that counts the bytes written?

from conscrypt.

dave-r12 avatar dave-r12 commented on August 26, 2024

@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.

from conscrypt.

nmittler avatar nmittler commented on August 26, 2024

@dave-r12 yeah that's right.

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?

from conscrypt.

dave-r12 avatar dave-r12 commented on August 26, 2024

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.

from conscrypt.

nmittler avatar nmittler commented on August 26, 2024

@flooey is this still on the radar? It would be good to have a single socke impl.

from conscrypt.

flooey avatar flooey commented on August 26, 2024

@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.

from conscrypt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.