Skip to content

Commit

Permalink
deps: track rustls alpha.6, pki-types 0.2.3 (#368)
Browse files Browse the repository at this point in the history
Brings in the change to use `pki-types` for `ServerName`.

Takes a temporary quality-of-life patch for pki-types.
  • Loading branch information
cpu authored Nov 29, 2023
1 parent a26a3d4 commit 49adcee
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 22 deletions.
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ read_buf = ["rustls/read_buf"]

[dependencies]
# Keep in sync with RUSTLS_CRATE_VERSION in build.rs
rustls = { version = "=0.22.0-alpha.4", features = [ "ring" ]}
rustls-webpki = "0.102.0-alpha.6"
pki-types = { package = "rustls-pki-types", version = "0.2.1", features = ["std"] }
rustls = { version = "=0.22.0-alpha.6", features = [ "ring" ]}
pki-types = { package = "rustls-pki-types", version = "0.2.3", features = ["std"] }
webpki = { package = "rustls-webpki", version = "=0.102.0-alpha.8", features = ["std"] }
libc = "0.2"
sct = "0.7"
rustls-pemfile = { version = "2.0.0-alpha.1" }
rustls-pemfile = "=2.0.0-alpha.2"
log = "0.4.17"

[lib]
Expand Down
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::io::Write;
use std::{env, fs, path::PathBuf};

// Keep in sync with Cargo.toml.
const RUSTLS_CRATE_VERSION: &str = "0.22.0-alpha.4";
const RUSTLS_CRATE_VERSION: &str = "0.22.0-alpha.6";

fn main() {
let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
Expand Down
13 changes: 4 additions & 9 deletions src/client.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::borrow::Cow;
use std::convert::TryInto;
use std::ffi::CStr;
use std::fmt::{Debug, Formatter};
Expand Down Expand Up @@ -79,7 +78,7 @@ impl ServerCertVerifier for NoneVerifier {
&self,
_end_entity: &CertificateDer,
_intermediates: &[CertificateDer],
_server_name: &rustls::ServerName,
_server_name: &pki_types::ServerName<'_>,
_ocsp_response: &[u8],
_now: UnixTime,
) -> Result<ServerCertVerified, rustls::Error> {
Expand Down Expand Up @@ -255,16 +254,12 @@ impl ServerCertVerifier for Verifier {
&self,
end_entity: &CertificateDer,
intermediates: &[CertificateDer],
server_name: &rustls::ServerName,
server_name: &pki_types::ServerName<'_>,
ocsp_response: &[u8],
_now: UnixTime,
) -> Result<ServerCertVerified, rustls::Error> {
let cb = self.callback;
let server_name: Cow<'_, str> = match server_name {
rustls::ServerName::DnsName(n) => n.as_ref().into(),
rustls::ServerName::IpAddress(ip) => ip.to_string().into(),
_ => return Err(rustls::Error::General("unknown name type".to_string())),
};
let server_name = server_name.to_str();
let server_name: rustls_str = match server_name.as_ref().try_into() {
Ok(r) => r,
Err(NulByte {}) => return Err(rustls::Error::General("NUL byte in SNI".to_string())),
Expand Down Expand Up @@ -555,7 +550,7 @@ impl rustls_client_config {
Ok(s) => s,
Err(std::str::Utf8Error { .. }) => return rustls_result::InvalidDnsNameError,
};
let server_name: rustls::ServerName = match server_name.try_into() {
let server_name: pki_types::ServerName = match server_name.try_into() {
Ok(sn) => sn,
Err(_) => return rustls_result::InvalidDnsNameError,
};
Expand Down

0 comments on commit 49adcee

Please sign in to comment.