/** * Public keys are encoded with the X509 public key spec. * * @param encodedPublic * @return */ public static PublicKey fromX509PEM(String encodedPublic) { return fromX509DER(PEMFormatUtil.getBodyBytes(encodedPublic, BEGIN_PUBLIC_KEY, END_PUBLIC_KEY)); }
/** * This takes the PEM encoding of a PKCS 8 format private key, strips the header and footer, converts * to bytes then invokes {@link #fromPKCS8DER(byte[])}. * You can get a PKCS #8 private key that is PEM encoded from open ssl e.g. with * <code> * openssl pkcs8 -topk8 -nocrypt -in privkey.pem -inform PEM -out privkey-pkcs8.pem -outform PEM * </code><br><br> * * @param pem * @return * @throws edu.uiuc.ncsa.security.core.exceptions.GeneralException * */ public static PrivateKey fromPKCS8PEM(String pem) throws GeneralException { return fromPKCS8DER(PEMFormatUtil.getBodyBytes(pem, BEGIN_PRIVATE_KEY, END_PRIVATE_KEY)); }