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

SSL error while using async_tls #36

Open
localacct opened this issue Sep 16, 2020 · 2 comments
Open

SSL error while using async_tls #36

localacct opened this issue Sep 16, 2020 · 2 comments

Comments

@localacct
Copy link

Hi

When I tried to use async_tls to establish a TLS connection to a ncat instance (using self signed certificates that I generated), I saw this error from the ncat terminal and the connection just close.

Ncat: Failed SSL connection from 127.0.0.1: error:00000000:lib(0):func(0):reason(0)

I noticed on Wireshark that the program attempts the normal TCP handshake and then followed by FIN-ACK to close the connection. I did not see the TLS protocol being initiated. I followed the code snippet from async_tls' documentation.

async_std::task::block_on(async {
    let connector = TlsConnector::default();
    let tcp_stream = async_std::net::TcpStream::connect("127.0.0.1:4444").await?;
    let encrypted_stream = connector.connect("127.0.0.1:4444", tcp_stream).await?;

    Ok(()) as async_std::io::Result<()>
});

Could this be related to the certificate not being accepted? I tried looking at async_tls' and rustls' documentation but I did not find options for me to accept self signed certificates or other dangerous options that native_tls has.

@localacct
Copy link
Author

Hi

I tried making some changes to my code but I am still seeing the same error, not sure where it went wrong.

	let mut customroot = rustls::RootCertStore::empty();

	let mut serverpem = File::open("custom_ca.pem")?;
	let mut serverpem = BufReader::new(serverpem);

	let der_formatted = rustls::internal::pemfile::certs(&mut serverpem).unwrap();

	for server_ca in &der_formatted
	{
		customroot.add(server_ca);
	}

	let mut clientconfig = rustls::ClientConfig::new();
        clientconfig.enable_sni = false;
        clientconfig.root_store = customroot;

        let async_connector = async_tls::TlsConnector::from(clientconfig);

	let tcp_stream = async_std::net::TcpStream::connect("127.0.0.1:4444").await?;
        let encrypted_stream = async_connector.connect("127.0.0.1:4444", tcp_stream).await?;

@skade
Copy link
Collaborator

skade commented Dec 4, 2020

I sadly have no ncat at hand - is this also when just using rusttls directly?

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

2 participants