Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I get the CN? #21

Open
MarkSwanson opened this issue May 18, 2017 · 5 comments
Open

Can I get the CN? #21

MarkSwanson opened this issue May 18, 2017 · 5 comments

Comments

@MarkSwanson
Copy link

With an older version of Hyper using OpenSSL I could do something like this:

 if let Some(sslstream) = request.ssl::<SslStream<HttpStream>>() {
            let ssl: &Ssl = sslstream.ssl();
            let peer_x509: X509 = ssl.peer_certificate().unwrap();
            let sn = peer_x509.subject_name();
            cn = sn.text_by_nid(Nid::CN).unwrap();
            debug!("cn: {}", &cn);
        }

I need the CN to do anything useful on our corporate network.
Is it possible to do something like this when I'm using hyper-rustls?
If yes, how?

Thanks!

@alex
Copy link
Contributor

alex commented Sep 22, 2017

I've been struggling with the same challenge of how to get at the client certificate: hyperium/hyper#1241

I haven't been able to figure out how to implement any of those suggestions though.

Has anyone been able to determine if this is actually possible at the moment, and if not, what's the best way to contribute to making it happen?

@alex
Copy link
Contributor

alex commented Sep 23, 2017

Ultimate solution was just to drop tokio-proto and have my own incoming() stream where I could grab the ServerSession from the TlsStream

@lucab
Copy link
Contributor

lucab commented Sep 23, 2017

@alex I'm not too familiar with proto/service myself, but yes I think the only away is to write your own logic on top of tokio-rustls, without using the proto portion of that crate.
I think the end result will look quite similar to tokio-rustls server example but I'm not sure about the hyper part.

Would you mind sharing a gist with your current solution? Does it completely bypass hyper-rustls? Depending on the final result it may (or may not) be helpful to have it here as a proto-less server example.

@alex
Copy link
Contributor

alex commented Sep 23, 2017 via email

@alex
Copy link
Contributor

alex commented Oct 22, 2018

Following up a year later (😬), the solution I put in that gist was working well, but the latest release of hyper no longer has the bind_connection API, and I'm struggling to figure out what the new way of expressing the same thing is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants