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

Two way TLS handshake error #1003

Open
hank179 opened this issue Nov 8, 2022 · 0 comments
Open

Two way TLS handshake error #1003

hank179 opened this issue Nov 8, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@hank179
Copy link

hank179 commented Nov 8, 2022

Version
warp = {version = "0.3.3", features = ["tls"]}

Platform
macOS 12.5

Description
I am trying to setup dual TLS for warp, however the TLS handshake fails on client authorization.

Code snippet:

    async fn handler() -> Result<impl Reply, Rejection> {
        Ok("success".to_string())
    }

    #[tokio::main]
    pub async fn web_service() {
        let metrics_route = warp::path("metrics").and(warp::get()).and(warp::path::end()).and_then(handler);
        warp::serve(metrics_route)
            .tls()
            .cert_path("server/cert.pem")
            .key_path("server/rsaprivkey.pem")
            .client_auth_required_path("client/cert.pem")
            .run(([0, 0, 0, 0], 9100)).await;
    }

Private keys and certificate generation (separately in client and server folders):

openssl genrsa -out rsaprivkey.pem 2048
openssl pkcs8 -topk8 -inform PEM -outform PEM -in rsaprivkey.pem -out rsaprivkey8.pem -nocrypt
openssl req -new -x509 -key rsaprivkey8.pem -out cert.pem
rm rsaprivkey.pem 
mv rsaprivkey8.pem rsaprivkey.pem 

To test:

  1. start web_service
  2. in terminal:
    run openssl s_client -connect localhost:9100 -cert client/cert.pem -key client/rsaprivkey.pem -CAfile server/cert.pem -debug
    output:
***
4377953664:error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure:ssl/record/rec_layer_s3.c:1544:SSL alert number 40

OR

run curl -k -iv --cert client/cert.pem --key client/rsaprivkey.pem --cacert server/cert.pem https://localhost:9100
output:

*   Trying 127.0.0.1:9100...
* Connected to localhost (127.0.0.1) port 9100 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*  CAfile: server/cert.pem
*  CApath: none
* (304) (OUT), TLS handshake, Client hello (1):
* (304) (IN), TLS handshake, Server hello (2):
* (304) (IN), TLS handshake, Unknown (8):
* (304) (IN), TLS handshake, Request CERT (13):
* (304) (IN), TLS handshake, Certificate (11):
* (304) (IN), TLS handshake, CERT verify (15):
* (304) (IN), TLS handshake, Finished (20):
* (304) (OUT), TLS handshake, Certificate (11):
* (304) (OUT), TLS handshake, CERT verify (15):
* (304) (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / AEAD-CHACHA20-POLY1305-SHA256
* ALPN, server accepted to use h2
* Server certificate:
*  subject: C=AU; ST=Some-State; O=Internet Widgits Pty Ltd
*  start date: Nov  8 08:38:26 2022 GMT
*  expire date: Dec  8 08:38:26 2022 GMT
*  issuer: C=AU; ST=Some-State; O=Internet Widgits Pty Ltd
*  SSL certificate verify ok.
* Using HTTP2, server supports multiplexing
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x140014000)
> GET / HTTP/2
> Host: localhost:9100
> user-agent: curl/7.79.1
> accept: */*
> 
* LibreSSL SSL_read: error:1404C410:SSL routines:ST_OK:sslv3 alert handshake failure, errno 0
* Failed receiving HTTP2 data
* LibreSSL SSL_write: SSL_ERROR_SYSCALL, errno 0
* Failed sending HTTP2 data
* Connection #0 to host localhost left intact
curl: (56) LibreSSL SSL_read: error:1404C410:SSL routines:ST_OK:sslv3 alert handshake failure, errno 0

Everything works fine when I disable client authentication. It may be that I misunderstand the way dual TLS should be used, but I spent a lot of time trying to make this work (including different ways and types of ssl keys and certificates)

@hank179 hank179 added the bug Something isn't working label Nov 8, 2022
@hank179 hank179 changed the title Dual TLS handshake error Tow way TLS handshake error Nov 8, 2022
@hank179 hank179 changed the title Tow way TLS handshake error Two way TLS handshake error Nov 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant