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

Exported public key in openssl format not readable #169

Closed FabianDat closed 5 years ago

FabianDat commented 5 years ago

The exported public key of a key pair is not readable by cat on mac os x. Same issue, if a Windows 10 user is exporting a key. I created a RSA Key Pair with size 2048, version 3 and SHA-256. Result: ?0?0 *?H?? ????>O?m?2 h?11??]?U?q??T?3?4}? )l/?\4?E ???lr?3????/?{U[@?OP?????{??7?V?u?2?)z)cFxK⛫???,G8ˮ x?試ud???(?X?3?^???%b?? w|?????W???)????r0??????thv]ޱ???U?????G??kc?8??1c?!?j??v????'???yמּvJ?????ŎLw???h??-?? }4??[??O?

Steps to reproduce the behavior:

  1. Right click Keypair
  2. export
  3. export public key
  4. uncheck pem
  5. press Button export.
  6. in mac terminal go to export location
  7. cat publickey.pub The resulting public key in openssl format is not readably by cat and does not work inside authorized_keys on my server.

Expected an output like: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD...... fabiand@MacBook-Pro.local

Version of KSE: 5.4.1 Version of Java: 1.8.0_201 Platform (OS): Mac OS X Version 10.12.6 (x86_64)

kaikramer commented 5 years ago

OpenSSH uses its own format for public keys, but you can convert the file by doing this:

  1. Export public key as PEM (let PEM checked)
  2. ssh-keygen -f publickey.pub -i -mPKCS8
kaikramer commented 5 years ago

And by the way, if you uncheck "PEM" the export format is binary SubjectPublicKeyInfo as defined in RFC 5280.