Skip to content

Can I get the CN? #21

Open
Open

Description

@MarkSwanson

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!

Activity

  1. alex commented on Sep 22, 2017

    @alex
    Contributor

    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?

  2. alex commented on Sep 23, 2017

    @alex
    Contributor

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

  3. lucab commented on Sep 23, 2017

    @lucab
    Contributor

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

  4. alex commented on Sep 23, 2017

    @alex
    Contributor
  5. alex commented on Oct 22, 2018

    @alex
    Contributor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions