Closed songtianyi closed 3 years ago
upgrade to jsonrpsee-ws-client = "0.2.0-alpha.3" fixed this
Ok, I'm quite surprised by this I think https://github.com/paritytech/jsonrpsee/pull/209 fixed this.
Which version did you get this on?
AFAIK, all 0.2.0-alpha.x
releases should work...
Ok, I'm quite surprised by this I think #209 fixed this.
Which version did you get this on? AFAIK, all
0.2.0-alpha.x
releases should work...
jsonrpsee-ws-client = "0.2.0-alpha.2" still does
I can't reproduce this, are you sure? Can you double check Cargo.lock
please?
However, don't matter that much when alpha.3
works
I got the same error when trying to connect to a server with a self signed cert. Could this be the same issue? Any way to get it to work with self signed certs?
Running version 0.2.0-alpha.6 with RUST_LOG=debug
env_logger::init();
let client = WsClientBuilder::default().build("wss://some-domain:1234").await.unwrap();
[2021-05-05T21:29:17Z DEBUG rustls::client::hs] No cached session for DNSNameRef("some-domain")
[2021-05-05T21:29:17Z DEBUG rustls::client::hs] Not resuming any session
[2021-05-05T21:29:18Z DEBUG rustls::client::hs] Using ciphersuite TLS13_AES_256_GCM_SHA384
[2021-05-05T21:29:18Z DEBUG rustls::client::tls13] Not resuming
[2021-05-05T21:29:18Z DEBUG rustls::client::tls13] TLS1.3 encrypted extensions: []
[2021-05-05T21:29:18Z DEBUG rustls::client::hs] ALPN protocol is None
[2021-05-05T21:29:18Z WARN rustls::session] Sending fatal alert BadCertificate
[2021-05-05T21:29:18Z DEBUG jsonrpsee_ws_client::transport] Failed to connect to sockaddr: some-ip:1234 with err: Io(Custom { kind: InvalidData, error: WebPKIError(CAUsedAsEndEntity) })
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: TransportError(NoAddressFound)', src/main.rs:26:91
It's not the same issue, the issue before was that the hostname and target were confused
This is probably a bad certificate.
Are you sure that you generated the self-signed certificate correctly? Can you try to generate the certificate by the following
$ openssl req -x509 -newkey rsa:4096 -keyout server.key -out server.crt -days 365 -sha256 -nodes --subj '/CN=localhost/'
Ok, thanks a lot! Will give it a try as soon as I can :)
Hi, I just tried running
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -sha256 -nodes --subj '/CN=localhost/'
I can access the site using chrome just fine and make sure the new cert is in use. However I still get an error.
By the way, the thing I am trying to access is a my Xen Orchestra server, a web based management tool for virtual machines written in js(if this is relevant).
[2021-05-15T14:01:28Z DEBUG rustls::client::hs] No cached session for DNSNameRef("localhost")
[2021-05-15T14:01:28Z DEBUG rustls::client::hs] Not resuming any session
[2021-05-15T14:01:28Z DEBUG rustls::client::hs] Using ciphersuite TLS13_AES_256_GCM_SHA384
[2021-05-15T14:01:28Z DEBUG rustls::client::tls13] Not resuming
[2021-05-15T14:01:28Z DEBUG rustls::client::tls13] TLS1.3 encrypted extensions: []
[2021-05-15T14:01:28Z DEBUG rustls::client::hs] ALPN protocol is None
[2021-05-15T14:01:28Z WARN rustls::session] Sending fatal alert BadCertificate
[2021-05-15T14:01:28Z DEBUG jsonrpsee_ws_client::transport] Failed to connect to sockaddr: [::1]:443 with err: Io(Custom { kind: InvalidData, error: WebPKIError(CAUsedAsEndEntity) })
[2021-05-15T14:01:28Z DEBUG rustls::client::hs] No cached session for DNSNameRef("localhost")
[2021-05-15T14:01:28Z DEBUG rustls::client::hs] Not resuming any session
[2021-05-15T14:01:28Z DEBUG rustls::client::hs] Using ciphersuite TLS13_AES_256_GCM_SHA384
[2021-05-15T14:01:28Z DEBUG rustls::client::tls13] Not resuming
[2021-05-15T14:01:28Z DEBUG rustls::client::tls13] TLS1.3 encrypted extensions: []
[2021-05-15T14:01:28Z DEBUG rustls::client::hs] ALPN protocol is None
[2021-05-15T14:01:28Z WARN rustls::session] Sending fatal alert BadCertificate
[2021-05-15T14:01:28Z DEBUG jsonrpsee_ws_client::transport] Failed to connect to sockaddr: 127.0.0.1:443 with err: Io(Custom { kind: InvalidData, error: WebPKIError(CAUsedAsEndEntity) })
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Transport(NoAddressFound)'
Do you think there is something I am doing wrong on the server side? :)
No, it turns out it that we don't support self-signed certificates.
I can open issue for, it turns out that async-tls
requires us to manually to input the certificate for it to work, such as https://github.com/async-rs/async-tls/blob/master/examples/client/src/main.rs#L83-#L92.
It should be quite straight-forward to add:
custom_certificate: Path
or something.AsyncTls::Connector
.Just starting experimenting down a quite similar path. I have some (not too great looking) code, I will try to improve it and open a PR.
jsonrpsee new client report error on vaild wss address To reproduce the error