GithubHelp home page GithubHelp logo

Comments (6)

svanharmelen avatar svanharmelen commented on May 29, 2024 2

Yeah that is clear (that rustls does not IO itself)...

Your solution seems like a perfect solution to use a higher level API instead of the lower level (now partly private) APIs we used before. I will give it a try and update the issues when I got a chance to test it.

Thank you very much for your help and the example!!

from rustls.

ctz avatar ctz commented on May 29, 2024 1

If you don't ever call into_connection() and then service the returned object for IO, nothing will happen. Remember rustls does no IO itself, so it has no real ability to accept the connection.

Here's a sample of decoding a client hello to read the SNI value:

fn main() {
    let client_hello = [
        22, 3, 1, 0, 229, 1, 0, 0, 225, 3, 3, 82, 109, 251, 33, 146, 168, 53, 86, 119, 127, 104,
        103, 229, 207, 90, 0, 60, 50, 71, 153, 239, 185, 68, 53, 28, 78, 90, 180, 131, 38, 213, 79,
        32, 245, 65, 141, 47, 134, 74, 85, 117, 157, 113, 190, 131, 101, 161, 239, 185, 23, 131,
        249, 81, 110, 181, 178, 73, 136, 231, 224, 104, 208, 145, 140, 118, 0, 20, 19, 2, 19, 1,
        19, 3, 192, 44, 192, 43, 204, 169, 192, 48, 192, 47, 204, 168, 0, 255, 1, 0, 0, 132, 0, 43,
        0, 3, 2, 3, 4, 0, 11, 0, 2, 1, 0, 0, 10, 0, 8, 0, 6, 0, 29, 0, 23, 0, 24, 0, 13, 0, 20, 0,
        18, 5, 3, 4, 3, 8, 7, 8, 6, 8, 5, 8, 4, 6, 1, 5, 1, 4, 1, 0, 23, 0, 0, 0, 5, 0, 5, 1, 0, 0,
        0, 0, 0, 0, 0, 14, 0, 12, 0, 0, 9, 108, 111, 99, 97, 108, 104, 111, 115, 116, 0, 51, 0, 38,
        0, 36, 0, 29, 0, 32, 185, 7, 102, 21, 198, 19, 186, 56, 168, 153, 237, 223, 201, 2, 247,
        62, 21, 207, 187, 23, 146, 248, 101, 251, 54, 83, 152, 253, 66, 172, 100, 39, 0, 45, 0, 2,
        1, 1, 0, 35, 0, 0,
    ];

    let mut acceptor = rustls::server::Acceptor::default();
    let cursor: &mut dyn std::io::Read = &mut &client_hello[..];
    acceptor.read_tls(cursor).unwrap();
    let maybe_accepted = acceptor
        .accept()
        .expect("invalid message received");
    let accepted = maybe_accepted.expect("`client_hello` was truncated");
    println!("sni: {:?}", accepted.client_hello().server_name());
}

from rustls.

svanharmelen avatar svanharmelen commented on May 29, 2024

I guess one route could be to try and create a ClientHello struct (and use its server_name method) from the bytes that I now use to create a OpaqueMessage (which I then use to create a Message which contains the ClientHelloPayload).

But its unclear to me how to do that (if its even possible)... Yet it seems that might be a better possible solution?

from rustls.

ctz avatar ctz commented on May 29, 2024

Are you using the Acceptor API? It makes the SNI value available in ClientHello::server_name(), accessible via Accepted::client_hello().

from rustls.

svanharmelen avatar svanharmelen commented on May 29, 2024

No we cannot use that because we do not want to accept the connection before we have determined the SNI (since we potentially need to route the connection to another service which will then accept the connection).

from rustls.

cpu avatar cpu commented on May 29, 2024

I'm going to close this since it sounds like there's a path forward. If you run into any additional issues we can reopen!

from rustls.

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.