Skip to content

Verify hostnames in SSL certificates #4954

Closed

Description

@mbrubeck

When visiting a site whose certificate is invalid because of a hostname mismatch (such as https://en.irfanview-forum.de/), Servo does not display any error.

OpenSSL does not automatically verify that the hostname in the URL matches the subject name or SAN (subject alternate name) in the certificate. The application must do this. It might make sense to put some of this functionality into Hyper.

Documentation:

Activity

  1. added
    I-wrong
    on Feb 18, 2015
  2. Manishearth commented on Feb 18, 2015

    @Manishearth
    Member

    I guess we'll need to set_verify and all?

  3. mbrubeck commented on Feb 18, 2015

    @mbrubeck
    ContributorAuthor

    We can use X509_VERIFY_PARAM_set1_host and set_verify if we require OpenSSL 1.0.2 or later.

    If we need to support older versions (currently we use 1.0.1 on Android, for example), we need to include code like this sample code.

  4. frewsxcv commented on Apr 26, 2015

    @frewsxcv
    Contributor

    Worth noting this is also an issue in Hyper: hyperium/hyper#472

  5. Manishearth commented on Apr 26, 2015

    @Manishearth
    Member

    Not exactly, hyper provides the right hooks, we just don't use them to their full extents.

  6. tarcieri commented on Apr 26, 2015

    @tarcieri

    I just started an RFC6125 hostname verification library for Rust:

    https://github.com/tarcieri/pkixnames

    I plan on modeling its behavior off of both Chrome and Firefox

  7. Manishearth commented on Apr 26, 2015

    @Manishearth
    Member

    cool!

    I'm pretty sure you just need to set the right flags in rust-openssl and it will do the verification for you.

    this is what we do (using these certificates obtained from Firefox via this script), but we need to set some more openssl flags manually there (I forgot which ones, but the functions here should give you some idea)

  8. tarcieri commented on Apr 26, 2015

    @tarcieri

    @Manishearth does rust-openssl implement RFC6125 itself? Prior to openssl "1.1.0" (i.e. unreleased), OpenSSL provided no native support for hostname verification.

  9. Manishearth commented on Apr 26, 2015

    @Manishearth
    Member

    No idea, you probably should check openssl-sys

    -----Original Message-----
    From: "Tony Arcieri" [email protected]
    Sent: ‎4/‎27/‎2015 12:12 AM
    To: "servo/servo" [email protected]
    Cc: "Manish Goregaokar" [email protected]
    Subject: Re: [servo] Verify hostnames in SSL certificates (#4954)

    @Manishearth does rust-openssl implement RFC6125 itself? Prior to openssl "1.1.0" (i.e. unreleased), OpenSSL provided no native support for hostname verification.
    —
    Reply to this email directly or view it on GitHub.

  10. tarcieri commented on Apr 26, 2015

    @tarcieri

    Basically what I'm saying is no released version of OpenSSL has native support for hostname verification, so if something is doing it, it's some code someone wrote in Rust themselves.

  11. Manishearth commented on Apr 26, 2015

    @Manishearth
    Member

    Ah, I see.

    An alternative is to bind to nss or pkix from the Mozilla tree, IIRC both are independent libraries. I recommend using pkix.

    -----Original Message-----
    From: "Tony Arcieri" [email protected]
    Sent: ‎4/‎27/‎2015 12:26 AM
    To: "servo/servo" [email protected]
    Cc: "Manish Goregaokar" [email protected]
    Subject: Re: [servo] Verify hostnames in SSL certificates (#4954)

    Basically what I'm saying is no released version of OpenSSL has native support for hostname verification, so if something is doing it, it's some code someone wrote in Rust themselves.
    —
    Reply to this email directly or view it on GitHub.

  12. tarcieri commented on Apr 26, 2015

    @tarcieri

    @Manishearth I'm basically planning on reimplementing the hostname verification part of pkix in pure Rust, FWIW

  13. Manishearth commented on Apr 26, 2015

    @Manishearth
    Member

    Alternatively, could you structure this so that it uses openssl for the cert checking, and then has its own verification method that operates on the cert and URL? Something that can be fed to the verification method of sslcontext.

    -----Original Message-----
    From: "Tony Arcieri" [email protected]
    Sent: ‎4/‎27/‎2015 12:26 AM
    To: "servo/servo" [email protected]
    Cc: "Manish Goregaokar" [email protected]
    Subject: Re: [servo] Verify hostnames in SSL certificates (#4954)

    Basically what I'm saying is no released version of OpenSSL has native support for hostname verification, so if something is doing it, it's some code someone wrote in Rust themselves.
    —
    Reply to this email directly or view it on GitHub.

  14. tarcieri commented on Apr 26, 2015

    @tarcieri

    Yep, that's exactly what my library vaporware library would allow you to do 😉

  15. 11 remaining items

  16. jdm commented on May 10, 2016

    @jdm
    Member

    My assumption is that it manifests as a network error inside Servo, and each network response consumer can choose how to handle those independently. For document loads, we display about:sslfail at the moment.

  17. mbrubeck commented on May 10, 2016

    @mbrubeck
    ContributorAuthor

    Note: We haven't updated to hyper 0.9.4, so Hyper's hostname verification is not in Servo master yet.

    I just built with hyper 0.9.4 locally, and https://blog.rust-lang.org/ loaded with no errors in Servo. (It should trigger a certificate verification error.) I'm not sure yet whether this is a bug in Servo or in Hyper...

  18. jdm commented on May 10, 2016

    @jdm
    Member

    I believe only the default client has hostname validation enabled by the changes in #784. We'll need to adapt them for our own code (see create_http_connector in http_loader.rs).

  19. jdm commented on May 10, 2016

    @jdm
    Member

    Although I guess we could verify it by seeing if wrap_client gets called in hyper.

  20. mbrubeck commented on May 10, 2016

    @mbrubeck
    ContributorAuthor

    Indeed, we are using hyper::net::Openssl instead of hyper::net::OpensslClient, and Openssl::wrap_client does not do set_verify_callback.

  21. mbrubeck commented on May 10, 2016

    @mbrubeck
    ContributorAuthor

    When I add a set_verify_callback, Servo just displays a blank page when I try to load a page with an invalid certificate. (This is the same thing it does for me on other network errors, like a hostname that doesn't resolve.)

  22. self-assigned this
    on May 10, 2016
  23. added 2 commits that reference this issue on May 10, 2016
    7aa10b8
    5695da0
  24. added a commit that references this issue on May 10, 2016
    40be84d
  25. added a commit that references this issue on May 10, 2016
    92e76e8
  26. added a commit that references this issue on May 26, 2016
    db2925d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-networkA-securityB-high-valueI-safetyI-wrong

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions