Skip to Content

How to export the Private Key from a SSL PSE?

Imagine that you purchased a SSL certificate from a given CA. This certificate was imported into a SSL PSE and used for HTTPS access. In certain landscapes, the same certificate should be imported in a different server or device (e.g. a reverse proxy). In order to import the certificate into the other server/device, you also need the private key from the PSE. How to export the private key from the SSL PSE?

First of all, SAPCRYPTOLIB 5.5.5 patch level 16 or higher is required. Then you can export your PSE file to a PKCS#12 file.

The command line is: sapgenpse export_p12 –p <YOUR_PSE> <P12_FILE>

Please note that you must provide a password for the PKCS#12 file!


Example:

PrivateKey1.png


The next step makes use of a third party tool, openssl. With this tool we can extract both keys (private and public one).

The openssl command line is: openssl pkcs12 -in <P12_FILE> -out <OUTPUT.txt> -nodes:

PrivateKey2.png


The same password must be provided above.

The Private Key is now available in the block BEGIN/END RSA PRIVATE KEY, as you can see below:


PrivateKey3.png


Of course, I have removed my private key… 馃槈

8 Comments
You must be Logged on to comment or reply to a post.
  • Hi Cristiano Hansen,

    We have a SUSE linux server. I am having trouble exporting the private key from SSL PSE. I am unable to figure out the procedure to execute this command in linux server

    “The command line is: sapgenpse export_p12 鈥損 <YOUR_PSE> <P12_FILE>”

     

    Kindly Help,

    sasank

     

    • Hi Sasank,

      It is quite simple. In a linux box, as system administrator (SIDadm account), you can run, for example:

      sapgenpse export_p12 -p SAPSSLS.pse privatekeyfile

      You will be asked for:

      Please enter PKCS#8 encryption password:

      and

      For verification, please reenter password:

      Later, if you list the directory content, you will find a p12 file, with your private key.

      In the example above, it generated a file called privatekeyfile.p12

      Kind regards,

      Cris

  • Hello Cristiano, thanks for this helpful blog.

    I just replicated this process in my scenario:

    I have an SAP Web Dispatcher as a proxy with a valid certificate installed, which is a wildcard SSL cert. I want to install the same certificate in an SAP ERP system, so I generated the PKCS12 file from the Web Dispatcher system, then the .txt with OpenSSL. I used the private key inside the .txt generated (just as you did) and this portal https://decoder.link/converter to join the private key and the actual certificate from CA provider, which is .p7b file to generate a new PKCS12 and install it in my SAP ERP system. However, it is not working when I upload my generated pkcs12 (which actually is a .pfx file) inside the SAP ERP system STRUST tcode. The message that STRUST throws is “Certificate response does not match PSE”.

    Do you have any idea what could be happening? How do you finally install the certificate in a different system?

    Thanks in advance for your support.

    BR!

    • Hi Andr茅s,

      If you already have a PSE in the web dispatcher with the wildcard certificate, you can take this PSE and then use STRUST to open it and then save it as the SSL server Standard PSE. There is no need to export/import certificates.

      Regards,

      Cris

      • Thanks a lot, Cristiano, you the man. I just tried it with the PSE as you mentioned and works super fine!

        On the other hand, I think I didn鈥檛 get correctly the scenario where the steps you depict in the blog apply for.

        Anyway, sincerely thanks.

        BR.

        Andr茅s.