2 unstable releases

Uses old Rust 2015

0.2.0 Aug 12, 2016
0.1.0 May 6, 2016

#19 in #hostname

Download history 433/week @ 2024-07-28 370/week @ 2024-08-04 886/week @ 2024-08-11 422/week @ 2024-08-18 534/week @ 2024-08-25 468/week @ 2024-09-01 393/week @ 2024-09-08 421/week @ 2024-09-15 527/week @ 2024-09-22 423/week @ 2024-09-29 86/week @ 2024-10-06 333/week @ 2024-10-13 312/week @ 2024-10-20 408/week @ 2024-10-27 382/week @ 2024-11-03 78/week @ 2024-11-10

1,206 downloads per month
Used in 9 crates (2 directly)

MIT/Apache

20KB
355 lines

rust-openssl-verify

Build Status

Documentation

Hostname verification for OpenSSL.

OpenSSL up until version 1.1.0 did not support verification that the certificate a server presents matches the domain a client is connecting to. This check is crucial, as an attacker otherwise needs only to obtain a legitimately signed certificate to some domain to execute a man-in-the-middle attack.

The implementation in this crate is based off of libcurl's.


lib.rs:

Hostname verification for OpenSSL.

OpenSSL up until version 1.1.0 did not support verification that the certificate a server presents matches the domain a client is connecting to. This check is crucial, as an attacker otherwise needs only to obtain a legitimately signed certificate to some domain to execute a man-in-the-middle attack.

The implementation in this crate is based off of libcurl's.

Examples

In most cases, the verify_callback function should be used in OpenSSL's verification callback:

extern crate openssl;
extern crate openssl_verify;

use std::net::TcpStream;
use openssl::ssl::{SslContext, SslMethod, SslStream, SSL_VERIFY_PEER, IntoSsl};
use openssl_verify::verify_callback;

let domain = "google.com";
let stream = TcpStream::connect((domain, 443)).unwrap();

let mut ctx = SslContext::new(SslMethod::Sslv23).unwrap();
ctx.set_default_verify_paths().unwrap();

let mut ssl = ctx.into_ssl().unwrap();
let domain = domain.to_owned();
ssl.set_verify_callback(SSL_VERIFY_PEER, move |p, x| verify_callback(&domain, p, x));

let ssl_stream = SslStream::connect(ssl, stream).unwrap();

Dependencies

~1.7–3MB
~68K SLoC