kaikramer / keystore-explorer

KeyStore Explorer is a free GUI replacement for the Java command-line utilities keytool and jarsigner.
https://keystore-explorer.org/
GNU General Public License v3.0
1.7k stars 275 forks source link

Allow DER encoded PKCS8 keys for examine clipboard #371

Closed bennypi closed 1 year ago

bennypi commented 2 years ago

We store key pairs in XML files and use the DER encoding for the X509 certificate and the key. Sometimes, I want to create a keystore from the certificate and key to use it in other places. I would like to use this workflow:

  1. Copy the base64String of the certificate to the clipboard
  2. "Examine System Clipboard" of KSE to export the certificate to a file
  3. Copy the base64String of the key to the clipboard
  4. "Examine System Clipboard" of KSE to export the key to a file
  5. "Import Key Pair", select PKCS8, select the previously exported files
  6. The entry is created and added to the key store.

This workflow works fine for the certificate where KSE is able to parse it and offers me the certificate view with the export function. However, KSE can not parse the base64String of the key.

In order to make KSE parse the key, the following steps have to be done: Create a textfile, add the BEGIN PRIVATE KEY header, copy the base64String and break it every 64 chars and lastly add the END PRIVATE KEY footer. Now if I copy the whole content of this textfile to the clipboard, KSE can parse the content and let's me export the key to continue my workflow to import the key pair.

I am not a crypto expert, but I would assume that it should be possible to parse the base64String of the key without the PEM header and footer.

kaikramer commented 2 years ago

Yes, that should be possible. Usually the PEM header is there so the content (header data and base 64 encoded data) can be correctly parsed, but in case of PKCS#8 that is no problem.

I'll try to squeeze that in the next bugfix release.