-
Notifications
You must be signed in to change notification settings - Fork 13.3k
BearSSL Max Fragment Length Negotation and Node.js server #5929
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
Changes from 3 commits
e94d1e3
f727636
092c43d
532a553
6006e8d
3ecacf4
f920652
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,17 +17,22 @@ const char *pass = STAPSK; | |
| void fetch(BearSSL::WiFiClientSecure *client) { | ||
| client->write("GET / HTTP/1.0\r\nHost: tls.mbed.org\r\nUser-Agent: ESP8266\r\n\r\n"); | ||
| client->flush(); | ||
| uint32_t to = millis() + 5000; | ||
| uint32_t startMillis = millis(); | ||
| do { | ||
| char tmp[32]; | ||
| memset(tmp, 0, 32); | ||
| // memset(tmp, 0, 32); | ||
| int rlen = client->read((uint8_t*)tmp, sizeof(tmp) - 1); | ||
| yield(); | ||
| if (rlen < 0) { | ||
| break; | ||
| } | ||
| if (rlen == 0) { | ||
| delay(10); // Give background processes some time | ||
| continue; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @d-a-v If there is no data available yet (rlen == 0), without delay I experienced timeout errors. My assumption is that this is because with no data available the loop that keeps the ESP busy reduces almost to:
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did experienced timeout error @80MHz even with With delay, average duration over about 20 request is 273.5ms, and 249.6ms without (measuring the while loop). Can you retry at 160MHz and see if you still have those timeouts (that I have with master @80Mhz) ? To be honest, I am concerned about this delay and the associated comment which is wrong to me.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I agree with saying the arduino infinite loop way of coding is wrong. In that case we could "delay-and-reduce-cpu-activity-until-a byte-is-received" and this api/call is lacking in our API. We are not in an RTOS, but maybe something is doable for this common case.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I always run the ESP8266 @ 160MHz when using BearSSL, so I experienced the timeout without the delay @ 160MHz and never tried @ 80MHz.
I asume you are not looking for just changing the text of the comment?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I too can be picky :) There are already two approvals and changes worksforme (and it's nice). So I let it go as-is. When my pickyness will be boiling I'll make a proposal for the comment-only.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ;-) |
||
| } | ||
| tmp[rlen] = '\0'; | ||
| Serial.print(tmp); | ||
| } while (millis() < to); | ||
| } while (millis() - startMillis < 5000); | ||
| client->stop(); | ||
| Serial.printf("\n-------\n"); | ||
| } | ||
|
|
@@ -73,11 +78,11 @@ int fetchMaxFragmentLength() { | |
|
|
||
| BearSSL::WiFiClientSecure client; | ||
| client.setInsecure(); | ||
| bool mfln = client.probeMaxFragmentLength("tls.mbed.org", 443, 1024); | ||
| bool mfln = client.probeMaxFragmentLength("tls.mbed.org", 443, 512); | ||
| Serial.printf("\nConnecting to https://tls.mbed.org\n"); | ||
| Serial.printf("MFLN supported: %s\n", mfln ? "yes" : "no"); | ||
| if (mfln) { | ||
| client.setBufferSizes(1024, 1024); | ||
| client.setBufferSizes(512, 512); | ||
| } | ||
| client.connect("tls.mbed.org", 443); | ||
| if (client.connected()) { | ||
|
|
@@ -125,6 +130,6 @@ void loop() { | |
| yield(); | ||
|
|
||
| Serial.printf("\n\n"); | ||
| Serial.printf("Default SSL: %d bytes used\n", a); | ||
| Serial.printf("1024 byte MFLN SSL: %d bytes used\n", b); | ||
| Serial.printf("Default SSL: %d bytes used\n", a); | ||
| Serial.printf("512 byte MFLN SSL: %d bytes used\n", b); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.