Package io.grpc.util

Class CertificateUtils


  • @ExperimentalApi("https://github.com/grpc/grpc-java/issues/8024")
    public final class CertificateUtils
    extends java.lang.Object
    Contains certificate/key PEM file utility method(s).
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.security.PrivateKey getPrivateKey​(java.io.InputStream inputStream)
      Generates a PrivateKey from a PEM file.
      static java.security.cert.X509Certificate[] getX509Certificates​(java.io.InputStream inputStream)
      Generates X509Certificate array from a PEM file.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CertificateUtils

        public CertificateUtils()
    • Method Detail

      • getX509Certificates

        public static java.security.cert.X509Certificate[] getX509Certificates​(java.io.InputStream inputStream)
                                                                        throws java.security.cert.CertificateException
        Generates X509Certificate array from a PEM file. The PEM file should contain one or more items in Base64 encoding, each with plain-text headers and footers (e.g. -----BEGIN CERTIFICATE----- and -----END CERTIFICATE-----).
        Parameters:
        inputStream - is a InputStream from the certificate files
        Throws:
        java.security.cert.CertificateException
      • getPrivateKey

        public static java.security.PrivateKey getPrivateKey​(java.io.InputStream inputStream)
                                                      throws java.io.UnsupportedEncodingException,
                                                             java.io.IOException,
                                                             java.security.NoSuchAlgorithmException,
                                                             java.security.spec.InvalidKeySpecException
        Generates a PrivateKey from a PEM file. The key should be PKCS #8 formatted. The key algorithm should be "RSA" or "EC". The PEM file should contain one item in Base64 encoding, with plain-text headers and footers (e.g. -----BEGIN PRIVATE KEY----- and -----END PRIVATE KEY-----).
        Parameters:
        inputStream - is a InputStream from the private key file
        Throws:
        java.io.UnsupportedEncodingException
        java.io.IOException
        java.security.NoSuchAlgorithmException
        java.security.spec.InvalidKeySpecException