2
votes

I tried to create a self-signed certificate based on the instructions in the link in Security key and cert for mosca MQTT broker.

$ openssl genrsa -des3 -out tls-key.pem 1024 (works fine)

$ openssl req -new -key tlk-key -out server.csr (returns error)

The error looks like this on cygwin;

Error opening Private Key tlk-key 6870300:error:02001002:system library:fopen:No such file or directory:bss_file.c:391:fopen('tlk-key','rb') 6870300:error:20074002:BIO routines:FILE_CTRL:system lib:bss_file.c:393: unable to load Private Key

On Ubuntu 16.04, the error looks like this;

Error opening Private Key tlk-key 140137729443480:error:02001002:system library:fopen:No such file or directory:bss_file.c:398:fopen('tlk-key','r') 140137729443480:error:20074002:BIO routines:FILE_CTRL:system lib:bss_file.c:400: unable to load Private Key

I tried with cygwin and Ubuntu. Can anyone advise what went wrong?

EDIT: I tried the command below after getting the answer from Steffen Ullrich. It still returns an error.

$ openssl req -new -key tlk-key.pem -out server.csr

Error opening Private Key tlk-key.pem 6870300:error:02001002:system library:fopen:No such file or directory:bss_file.c:391:fopen('tlk-key.pem','rb') 6870300:error:20074002:BIO routines:FILE_CTRL:system lib:bss_file.c:393: unable to load Private Key

1
The documentation seems to be pretty old. 3DES should not be used anymore and for RSA the recommended key size is 2048. - Robert
Robert , thanks. Do you have any links that point to newer documentation? - user781486
Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See What topics can I ask about here in the Help Center. Perhaps Super User or Unix & Linux Stack Exchange would be a better place to ask. Also see Where do I post questions about Dev Ops? - jww

1 Answers

2
votes

You create the key file tls-key.pem but then try to use the non-existing file tlk-key instead of the file you've created:

$ openssl genrsa -des3 -out tls-key.pem 1024 (works fine)
                            ^^^^^^^^^^^^
$ openssl req -new -key tlk-key -out server.csr (returns error)
                        ^^^^^^^