User Tools

Site Tools


wiki:tech:java-hints:java-and-certificates
converting openssl keys for usage in java

convert PKCS1 private key is PKCS8 (used in java.security.*)

openssl pkcs8 -topk8 -inform PEM -in private.key -outform pem -nocrypt -out pkcs8.pem

create x.509 certificate for private key

openssl req \
       -newkey rsa:2048 -nodes -keyout domain.key \
       -x509 -days 365 -out domain.crt
public/private keys formats and headers

Public formats

  • PKCS#1 (PEM header: BEGIN RSA PUBLIC KEY)
  • X.509 (PEM header: BEGIN PUBLIC KEY)
  • XML tag <RSAKeyValue>

Private key formats

  • PKCS#8 (PEM header: BEGIN ENCRYPTED PRIVATE KEY)
  • PKCS#1 (PEM header: BEGIN RSA PRIVATE KEY) - unencrypted
  • PKCS#8 (PEM header: BEGIN PRIVATE KEY) - unencrypted
  • XML <RSAKeyPair> and <RSAKeyValue>
wiki/tech/java-hints/java-and-certificates.txt · Last modified: 2020/11/23 17:23 by kpc