Cannot upload ESP8266 project due to SSLError - Wrong Version Number

Hi

I have just installed pio on vsc on windows 10 to try and code my esp8266.
I have an x86-64 based system.

when i try to upload the project onto my board, i get the below error.

Tool Manager: Installing platformio/tool-mkspiffs @ ~1.200.0
Error: HTTPSConnectionPool(host='api.registry.ns1.platformio.org', port=443): Max retries exceeded with url: /v3/packages/platformio/tool/tool-mkspiffs (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1123)')))

I have tried with no success.

  1. Temprarliy disabling my Avast antivirus - did not work
  2. running this from command prompt (my system cli) - same error occurred.

for debugging purposes when i visit the website PlatformIO Registry API in my browser, the SSL certificates i see are as below:

board: WeMos D1 R2 and mini

pio details

  • Core 5.1.1* ·
  • Home 3.3.4

VSC details
Version: 1.56.2 (user setup)
Commit: 054a9295330880ed74ceaedda236253b4f39a335
Date: 2021-05-12T17:13:13.157Z
Electron: 12.0.4
Chrome: 89.0.4389.114
Node.js: 14.16.0
V8: 8.9.255.24-electron.0
OS: Windows_NT x64 10.0.19042

Hm the requested URL https://api.registry.ns1.platformio.org/v3/packages/platformio/tool/tool-mkspiffs loads also just fine for me and the certificate is valid. The connection to the site uses TLS 1.3 for me in the browser, but with openssl s_client -host api.registry.ns1.platformio.org -port 443 it also shows TLS 1.2 as capability, so not sure what’s wrong…

Do you have any proxy set up in the system?

Hmmm… I have a server on my system which has a reverse proxy on. This also acts as my DNS for my network. As it has adguard home on.

Could this affect things?

It would seem strange to me if it’s triggering when executing PlatformIO / Python but not in your browser… you can give it a try though…

Maybe you also need to setup the proxy in VSCode? PlatformIO IDE for VSCode — PlatformIO latest documentation

Hi , I have tried connecting the laptop to my mobile hotspot ( which doesn’t use the same dns server) but i still get the same issue.

I am also not sure what the proxy settings should be/if i need them. I have already disabled strict ssl

Hm well I can definitely tell you that I don’t have this issue on my computer and network.

Processing esp8266 (platform: espressif8266; board: nodemcuv2; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Tool Manager: Installing platformio/tool-mkspiffs @ ~1.200.0
Tool Manager: tool-mkspiffs @ 1.200.0 has been installed!

Try removing the whole C:\Users\<user>\.platformio\ folder again to force a redownload of PlatformIO maybe.

Hi @maxgerhardt - thanks for your help.

Unfortunately it has not resolved the issue. Thank you for trying however

oh great ! by luck i saw an option to install an ealier version of PIO IDE - i installed V2.01 and i no longer have the same issue.

I will investigate to see what the latest version i can install and not have the issue is.

Thank you

Great! now that the tool has been installed, i have reverted back to the latest version and all works now. Thank you

Reverting a version, then updating back and it working doesn’t sound like healthy behavior for me, but if it’s really fixed, okay. You can try to remove the folder C:\Users\<user>\.platformio\packages\tool-mkspiffs and then re-execute a project task that needs mkspiffs, like “Build Filesystem Image”. If it fails to re-install tool-mkspiffs with the same error message, it’s still broken.

Could you please give a hint how to install a particular version of PlatformIO for VS Code on Windows? The upload used to work before a PlatformIO update, but it seems to be broken in latest PlatformIO. I see that it sends invalid data to proxy, talking binary protocol and not HTTP:

00:45:28.691052 IP pc.home.49266 > proxy.3128: Flags [P.], seq 1:518, ack 1, win 256, length 517                           
...
    0x0030:  fc03 03e6 e3fd f5b9 13d1 edab 6981 2eea  ............i...                                                                  
    0x0040:  ad76 ddc3 ec94 0169 a1c5 a209 a37b 7593  .v.....i.....{u.                                                                  
    0x0050:  75bf 4e20 8e1c f679 05a6 185c a8c8 8a6c  u.N....y...\...l                                                                  
    0x0060:  e039 a251 695b 7831 9ad8 7b83 cf34 44bd  .9.Qi[x1..{..4D.                                                                  
    0x0070:  6e2a 8cd3 0056 1302 1303 1301 c02c c030  n*...V.......,.0                                                                  
    0x0080:  c02b c02f cca9 cca8 009f 009e ccaa c0af  .+./............                                                                  
    0x0090:  c0ad c0ae c0ac c024 c028 c023 c027 c00a  .......$.(.#.'..
...
00:45:28.691586 IP proxy.3128 > pc.home.49266: Flags [.], seq 1:1461, ack 518, win 501, length 1460
...
	0x0020:  5010 01f5 89c4 0000 4854 5450 2f31 2e31  P.......HTTP/1.1
	0x0030:  2034 3030 2042 6164 2052 6571 7565 7374  .400.Bad.Request
	0x0040:  0d0a 5365 7276 6572 3a20 7371 7569 640d  ..Server:.squid.
	0x0050:  0a4d 696d 652d 5665 7273 696f 6e3a 2031  .Mime-Version:.1
	0x0060:  2e30 0d0a 4461 7465 3a20 5468 752c 2032  .0..Date:.Thu,.2
	0x0070:  3320 4a75 6e20 3230 3232 2032 323a 3435  3.Jun.2022.22:45
	0x0080:  3a32 3820 474d 540d 0a43 6f6e 7465 6e74  :28.GMT..Content
	0x0090:  2d54 7970 653a 2074 6578 742f 6874 6d6c  -Type:.text/html
	0x00a0:  3b63 6861 7273 6574 3d75 7466 2d38 0d0a  ;charset=utf-8..
	0x00b0:  436f 6e74 656e 742d 4c65 6e67 7468 3a20  Content-Length:.
	0x00c0:  3333 3236 0d0a 582d 5371 7569 642d 4572  3326..X-Squid-Er
	0x00d0:  726f 723a 2045 5252 5f50 524f 544f 434f  ror:.ERR_PROTOCO
	0x00e0:  4c5f 554e 4b4e 4f57 4e20 300d 0a56 6172  L_UNKNOWN.0..Var
...

VS Code console:

Tool Manager: Installing tool-mkspiffs @ ~1.200.0
Error: HTTPSConnectionPool(host='api.registry.nm1.platformio.org', port=443): Max retries exceeded with url: /v3/search?query=type%3A%22tool%22+name%3A%22tool-mkspiffs%22 (Caused by ProxyError('Your proxy appears to only use HTTP and not HTTPS, try changing your proxy URL to be HTTP. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#https-proxy-error-http-proxy', SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1129)'))))
The terminal process "C:\Users\admin\.platformio\penv\Scripts\platformio.exe 'run', '--target', 'upload'" terminated with exit code: 1.

I have tried with proxy set in VS Code Settings as well as with no proxy set – with the same result in both cases.
image

I have found the root of confusion. PlatformIO uses system-wide proxy settings, and not those from VS Code settings (or falls back to those settings). After resetting syste-wide proxy, PlatformIO was able to download the necessary modules:

Tool Manager: Installing tool-mkspiffs @ ~1.200.0
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Tool Manager: tool-mkspiffs@1.200.0 has been installed!
Tool Manager: Installing tool-mklittlefs @ ~1.203.0
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Tool Manager: tool-mklittlefs@1.203.210628 has been installed!

However the issue is still there: PlatformIO incorrectly talks to proxy server and then displays the misleading error (SSL: WRONG_VERSION_NUMBER).