Local server SSL .PEM error

Hio,

So I just managed to create my certificates with OpenSSL using the instructions in Docs section.

I was asked to create passwords twice, once for the key i think and once for the .PEM file.

I’ve tried just having a password in the PEM file and having in both. The password is made from numbers and letters
so no special characters. The server keeps throwing this at me:

  • ERROR - Error initializing ssl context. Reason : File does not contain valid private key: .\server.pem

This is my properties setup
server.ssl.cert=./server.crt
server.ssl.key=./server.pem
server.ssl.key.pass=**********

Am I missing something?
I just copy pasted the commands from docs, added my “data” with names and country codes and passwords.
Copied the files to my Blynk folder and updated the server.properties

And yes… I’ve double checked the passowrds :stuck_out_tongue:

1 Like

Hi, I just encountered the same error:
“ERROR- Error initializing ssl context. Reason : File does not contain valid private key: /home/pi/server.pem”

Please double check the file path and try this command lines, and re-generate everything.
openssl genrsa -out server.key 2048
openssl req -new -out server.csr -key server.key
openssl x509 -req -days 1825 -in server.csr -signkey server.key -out server.crt
openssl pkcs8 -topk8 -inform PEM -outform PEM -in server.key -out server.pem

OR
you can only do the last cmd to re-generate the pem.
MUST input a password when generating pem. Not just press Enter. (I think you did it already)
Restart the server, and my problem was solved. My server version is 0.24.0.

Don’t forget to update the fingerprint in your sketch if you re-generate a new crt.

Good luck!

2 Likes

Thanks, I’ll give it another go when my project goes live :stuck_out_tongue:

@benjaminzhao Thanks,
After few updates I always encounter a failure crash (:slight_smile:) , It didn’t make a password and previous versions were running just fine. Today when I tried v0.24.1, it gave me that error. Thanks to your reply to @Fettkeewl , I resigned my certificate with password and server started successfully again.

I hope server.properties changes are mentioned whenever server is updated to minimize pulling the remaining pile of hair on my head :grin:

Cheers

1 Like

I’ll do my best :wink:

GAHHHHHHHHHHHH :stuck_out_tongue: STILL THE SAME SHIT

Exception in thread “main” java.lang.RuntimeException: File does not contain valid private key: D:\Blynk\server.pem
at cc.blynk.utils.SslUtil.initSslContext(SslUtil.java:71)
at cc.blynk.server.hardware.HardwareSSLServer.(HardwareSSLServer.java:36)
at cc.blynk.server.launcher.ServerLauncher.start(ServerLauncher.java:78)
at cc.blynk.server.launcher.ServerLauncher.main(ServerLauncher.java:70)

Followed your steps, tried with and without password on server.key and both got me this error. So frustrating :smiley:
Paths are right, it finds the .pem as per error message.
When generating pem I gave it a password and said password is in the server.properties file. Heeeeeeeeeeeeeelp before I go nanas.

Edit : perhaps I should ask… What is considered a valid key?!

Delete the existing keys and crts. Try this.

openssl genrsa -out server.key 2048

openssl req -new -out server.csr -key server.key -config "Path to your OPENSSL config file, eg: C:\OpenSSL-Win64\bin\openssl.cfg"

openssl x509 -req -days 1500 -in server.csr -signkey server.key -out server.crt

openssl pkcs8 -topk8 -inform PEM -outform PEM -in server.key -out server.pem
1 Like

Thank you for your time but I gave that up now with auto certification :slight_smile:

2 posts were split to a new topic: Local Server encryption setup - File does not contain valid private key: /home/pi/Blynk/server.pem