Enter PEM pass phrase just once

11,112

Solution 1

As suggested by Mikael, you can remove the pass phrase from the Key. Do note that this presents a serious security risk.

To remove the pass phrase from the Key, perform the following steps. Say you have a file called foo.pem with the following contents:

-----BEGIN ENCRYPTED PRIVATE KEY-----
...
-----END ENCRYPTED PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----

Execute the following command:

openssl rsa -in foo.pem -out foo_unencrypted.pem

You will be prompted for the pass phrase, and in return receive a file foo_unencrypted.pem that contains the following:

-----BEGIN RSA PRIVATE KEY-----
...
-----END RSA PRIVATE KEY-----

This file is missing the BEGIN CERTIFICATE ---- END CERTIFICATE section from above, so copy-paste it from foo.pem to the end of foo_unencrypted.pem:

-----BEGIN RSA PRIVATE KEY-----
...
-----END RSA PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----

If you use the file foo_unencrypted.pem, you will now no longer be prompted to "Enter PEM pass phrase".

Solution 2

I eventually found this post: Auto enter pass phrase in case of Python ssl Client/Server where they suggest that you remove the pass phrase from the Key.

Share:
11,112
Mikael
Author by

Mikael

Updated on June 04, 2022

Comments

  • Mikael
    Mikael almost 2 years

    I have a loop that that run every 30 sec, connects to a SSL server (reactor.connectSSL()), send a message (self.transport.write(msg)) and then disconnect (self.transport.loseConnection()).

    The issue is that it asks "Enter PEM pass phrase" each time the loop try to connect. Is it possible to enter it just once?