-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Client certs removed from connection when setInsecure
called, causing SSL connect failure.
#7455
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
Comments
Just FYI, the certs that BearSSL are dumping are the public certs sent by the remote side, so there's not much reason to redact them. No private keys are in there. Since your MCVE can't be run by anyone but you (private client certs, etc.), it's going to be on you to debug this. It could be a 1) BearSSL protocol issue (unlikely, but possible), 2) a timeout on the AMZN server (negotiation takes a long time on the 8266 vs. a desktop) or the 8266-side, or 3) something else. For 1) I would suggest you use the tests/host For 2), you can look at the handshake times on the core (get For 3), I would suggest setting up a local mosquito server with your client certs and running there. You can use wireshark on the server to collect packet handshake between the two. I've run that a lot, actually, without issue. If your code has trouble there, then I'd look at something in the sketch as the culprit. I would also suggest using https://gitter.im/esp8266/Arduino or https://esp8266.com . I see you posted on gitter already, but you might want to start with "Anyone have a working AMZN MQTT" vs. the specific error your code's hitting to get better response. Good luck! |
Thanks for your feedback @earlephilhower! My bad redacting public certs :-) I am generally following AWS documentation for MQTT over SSL on an ESP32, the only real difference I encountered on the ESP8266 is that the interface to I've looked into a few more things with no joy yet:
I will look into your other suggestions next. Thanks again. |
@Gor-Ren You could also add some debug statements in _run_until. Looking at the BearSSL source I think this function will return a -1 in your case. Some returns from this function will generate a log, but a lot don't. Maybe you can drill down the issue in this way. |
BSSL:_wait_for_handshake: failed
when establishing SSL connectionsetInsecure
called, causing SSL connect failure.
I built a standalone HTTPS test and a Flask.py server requiring client certs and it worked fine. W/o the client cert, it failed. W/the cert, I connected and got a HTTPS GET request services. But, the order of
is good.
failed because I think that it may make sense to NOT touch client certs when |
WiFiClientSecure.setInsecure() was clearing the secret key (but not the _chain public client cert) incorrectly. The other server authentication modes also had the same effect. The only way for it to work would be if the app first set the server authentication method and then the client keys. There's no good reason for this. Adjust the connection to only clear the server id methods and leave the client ID untouched. Fixes esp8266#7455
@earlephilhower I remember that clearing the cert on setInsecure() was implemented on purpose, i. e. you had a good reason for it. |
I vaguely remember the discussion, but I am pretty sure the current setup doesn't make sense.
The client public cert/secret key only refer to the client proving it's who it says it is. It's not really related to the prior 4 calls and should be orthogonal to them. I think I just goofed. For example, the current setup clears the secret key but not the cert so I send crap to the BearSSL backend (which just doesn't sent any client cert). It should either clear them both or neither. |
I can confirm swapping the order of the |
WiFiClientSecure.setInsecure() was clearing the secret key (but not the _chain public client cert) incorrectly. The other server authentication modes also had the same effect. The only way for it to work would be if the app first set the server authentication method and then the client keys. There's no good reason for this. Adjust the connection to only clear the server id methods and leave the client ID untouched. Fixes #7455
Hey, any updates on this? I'm getting an Basic Infos
Platform
Settings in IDE
Problem DescriptionSo I got problems to do the handshake with my tesla powerwall (solar battery storage system) which I'm doing a project with. The powerwall did an update and unfortunately as described I can not connect to it anymore. I'm getting the Getting stuck here:(In my project in powerwall_ip = "192.168.178.38"
WiFiClientSecure httpsClient;
httpsClient.setInsecure();
httpsClient.setTimeout(10000);
int retry = 0;
while ((!httpsClient.connect(powerwall_ip, 443)) && (retry < 15)) {
delay(100);
Serial.print(".");
retry++;
}
if (retry >= 15) {
return ("CONN-FAIL");
}
Debug Messages
DebuggingI did some debugging with a friend and from the if (!(_client->state() == ESTABLISHED) && !WiFiClient::available()) {
return (state & target) ? 0 : -1;
} After this we just outputted the values of These would be the two values: /** \brief SSL engine state: engine may receive records from the peer. */
#define BR_SSL_RECVREC 0x0004
/** \brief SSL engine state: engine may accept application data to send. */
#define BR_SSL_SENDAPP 0x0008 Probably someone can help. |
hello sir, first sorry for my poor English I am working on node MCu 1.0 board v2.4.2. i uploaded the our ca certificate ,private key certificate and secure key in my board it is working fine. how to rectify this error ? |
@ElectricBeat, did you fix the problem with rc = -2? |
Basic Infos
Platform
Settings in IDE
Problem Description
I am attempting to publish a "hello world" MQTT message over WiFi to an Amazon Web Services (AWS) IoT endpoint, which requires SSL encryption. I have been issued a CA cert, device cert and device public & private keys, plus my account-specific AWS endpoint to publish against.
I have configured my sketch to use these credentials (but not currently using PROGMEM to store them), and I populate the
WifiClientSecure
with my device certificate and private key. For now I am ignoring server certificate verification usingWifiClientSecure::setInsecure
.my troubleshooting has included:
WifiClient
and successfully publish "hello worlds" to an unencrypted public MQTT broker.openssl s_client
CLI helper (output provided in debug section)The TLS handshake fails around
BSSL:_wait_for_handshake: failed
; please see debug output.Further troubleshooting advice greatly appreciated.
MCVE Sketch
Debug Messages
From a terminal, I can connect successfully using the same certificates:
(the certificates redacted in the sketch above are a copy-paste of the files referenced below)
And receive successful output:
The text was updated successfully, but these errors were encountered: