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

remove a seeming redundant code and possible clerical errors in examples/tls_rustls.rs #176

Closed
wants to merge 2 commits into from
Closed

Conversation

xiuno
Copy link

@xiuno xiuno commented Aug 12, 2021

when I run this example tls_rustls.rs cargo run --release is ok, then, curl -k http://127.0.0.1:3000/ got a error: response empty.

service info:

thread 'tokio-runtime-worker' panicked at 'called `Result::unwrap()` on an `Err` value: hyper::Error(Parse(VersionH2))', src/main.rs:

I try to check the example code, found keyword b"h2", when I remove it, all is ok.

@davidpdrsn
Copy link
Member

@programatik29 thoughts?

@programatik29
Copy link
Contributor

@xiuno Make it https://localhost:3000/ since you are testing tls not plaintext http.
@davidpdrsn

@xiuno
Copy link
Author

xiuno commented Aug 12, 2021

@xiuno Make it https://localhost:3000/ since you are testing tls not plaintext http.
@davidpdrsn

just I try to:
curl -k https://127.0.0.1:3000/abc
curl: (52) Empty reply from server

it works after remove b"h2".to_vec() yet.

@programatik29
Copy link
Contributor

@xiuno Make it https://localhost:3000/ since you are testing tls not plaintext http.
@davidpdrsn

just I try to:
curl -k https://127.0.0.1:3000/abc
curl: (52) Empty reply from server

it works after remove b"h2".to_vec() yet.

Are you running the example with cargo run --example tls_rustls ?

@xiuno
Copy link
Author

xiuno commented Aug 12, 2021

I try to run cargo run --example tls_rustls , it's ok!
after I create self sign certification, it works bad(curl -x https://127.0.0.1:3000/ enter loop waiting)! when I remove b"h2".to_vec() works
ok again!

make certification:

mkdir cert
cd cert
openssl genrsa -out root-key-pkcs1.key 2048
openssl pkcs8 -topk8 -inform PEM -in root-key-pkcs1.key -outform PEM
-nocrypt -out root-key-pkcs8.key
openssl req -new -out root-req.csr -key root-key-pkcs1.key -keyform PEM
-subj "/CN=localhost,AltName=DNS:localhost"
openssl x509 -req -extfile /usr/local/etc/openssl/openssl.cnf -extensions
v3_req  -in root-req.csr -out root-cert.cer -signkey root-key-pkcs1.key
-CAcreateserial -days 3650

change path of certification

let rustls_config = rustls_server_config(
        "cert/root-key-pkcs8.key",
        "cert/root-cert.cer",
);

server run:

cargo run --example tls_rustls

client request:

curl -x https://127.0.0.1:3000/

client enter loop waiting...

@programatik29
Copy link
Contributor

There is a http2 hanging problem currently. That is what causes hanging. #108 introduces it. Test again in #139.

@programatik29
Copy link
Contributor

There is a http2 hanging problem currently. That is what causes hanging. #108 introduces it. Test again in #139.

Also discovered that problem thanks to you @xiuno.

@davidpdrsn davidpdrsn added the T-docs Topic: documentation label Aug 16, 2021
@programatik29
Copy link
Contributor

h2 in alpn allows http2 protocol to be negotiated and used. Code is not redundant. Hanging bug is related to #191. This PR can be closed.

@davidpdrsn
Copy link
Member

Alright. I'll close this then. @xiuno let us know if there is more to discuss 😊

@davidpdrsn davidpdrsn closed this Aug 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-docs Topic: documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants