Comments (6)
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.
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.
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.
Are you using the Acceptor
API? It makes the SNI value available in ClientHello::server_name()
, accessible via Accepted::client_hello()
.
from rustls.
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.
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)
- 0.23 docs build is broken HOT 2
- optimize receiving data with TLS 1.2 and aes-128-gcm HOT 1
- optimize receiving data with TLS 1.3 and aes-256-gcm
- optimize server-side full handshakes for TLS 1.2 and 1.3 HOT 1
- Connection::dangerous_extract_secrets returns ConnectionTrafficSecrets::Aes128Gcm even when AES-256-GCM is negotiated
- Error: badRecordMac HOT 4
- Cipher suites configured through WebPkiServerVerifier::builder_with_provider is not working. Client hello contains more cipher suites then it configured. HOT 6
- rand_core::RngCore & CryptoRng support for CryptoProvider HOT 7
- expose more information in ClientHello HOT 4
- No common ciphersuit when FFDHE and ECDHE ciphersuites are available on server and client using TLS 1.2 HOT 4
- US Export control information HOT 4
- doc: AcceptedAlert::write doesn't necessarily write all bytes HOT 7
- Support using rustls without using specific ring or aws-lc-rs apis HOT 2
- Feature request: a way to set/get default ticketer dynamically HOT 6
- Feature Request: Avoid panicking when ring and aws_lc_rs are both specified HOT 12
- Option to Relax SNI Host Name Validation for IP Addresses HOT 7
- unbuffered: B: `CapacityBuffer` for `output_tls.capacity()` HOT 9
- The support for "mipsel-unknown-linux-musl" has failed. HOT 2
- Io(Custom { kind: InvalidData, error: AlertReceived(HandshakeFailure) }) HOT 6
- Linux compilation is slow and seems unable to store compilation results HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rustls.