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

Support connecting to IP addresses #564

Closed
Demi-Marie opened this issue Dec 14, 2019 · 9 comments
Closed

Support connecting to IP addresses #564

Demi-Marie opened this issue Dec 14, 2019 · 9 comments

Comments

@Demi-Marie
Copy link
Contributor

Quinn currently errors out if I try to connect to an IP address, presumably because webpki does not support them. However, my code uses a custom certificate verifier that does not use webpki.

@est31
Copy link
Contributor

est31 commented Dec 15, 2019

IDK it works for me (with my custom certificate verifier code).

@djc
Copy link
Member

djc commented Dec 15, 2019

@demimarie-parity can you elaborate on the exact error behavior you're seeing?

@burdges
Copy link

burdges commented Dec 15, 2019

In what repo is your code @est31 ?

@est31
Copy link
Contributor

est31 commented Dec 15, 2019

@burdges not public (yet). All I did was:

	/// A certificate verifier that accepts any certificate
	struct NullVerifier;
	impl rustls::ServerCertVerifier for NullVerifier {
		fn verify_server_cert(
			&self,
			_roots :&rustls::RootCertStore,
			_presented_certs :&[rustls::Certificate],
			_dns_name :webpki::DNSNameRef,
			_ocsp_response :&[u8],
		) -> Result<rustls::ServerCertVerified, rustls::TLSError> {
			Ok(rustls::ServerCertVerified::assertion())
		}
	}

	let mut client_config = quinn::ClientConfigBuilder::default();
	let mut client_config = client_config.build();
	// Trust all certificates
	Arc::get_mut(&mut client_config.crypto).unwrap().dangerous()
		.set_certificate_verifier(Arc::new(NullVerifier));

For the moment that's enough for my purposes.

@Demi-Marie
Copy link
Contributor Author

@djc I get InvalidDnsName from quinn_proto::generic::Endpoint::connect

@est31
Copy link
Contributor

est31 commented Dec 15, 2019

@demimarie-parity I'm hardcoding the hostname, maybe that's the difference?

let url = "127.0.0.1:4000";
let url = url.to_socket_addrs()?.next().expect("socket addr expected");
endpoint.connect(url, "something")?;

@Ralith
Copy link
Collaborator

Ralith commented Dec 15, 2019

See also briansmith/webpki#54 and rustls/rustls#184. If you hardcode a valid garbage hostname (e.g. any alphabetic ASCII string) and use a custom cert verifier I think that should get the behavior you want in lieu of extensions to the underlying libraries.

@djc
Copy link
Member

djc commented Dec 16, 2019

BTW, I know Brian Smith is open to adding support, but he has been looking for a sponsor for the work involved. Maybe Parity can support that?

@daxpedda
Copy link
Contributor

This should be supported since rustls/webpki#5.

@Ralith Ralith closed this as completed Jul 21, 2023
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

6 participants