public static RSAPublicKey getPublicKeyFromString(String certificateString)
    throws CertificateException, UnsupportedEncodingException {

    CertificateFactory fact = CertificateFactory.getInstance("X.509");
    ByteArrayInputStream is = new ByteArrayInputStream(
      certificateString.getBytes("UTF8"));

    X509Certificate cer = (X509Certificate) fact.generateCertificate(is);
    return (RSAPublicKey)cer.getPublicKey();
  }
Get RSA public key from X.509 certificate string (full crt file content, including header and footer)
@param certificateString certificate string
@return RSA public key
@throws CertificateException
@throws UnsupportedEncodingException
ambari-server/src/main/java/org/apache/ambari/server/security/encryption/CertificateUtils.java