Package io.grpc.util
Class CertificateUtils
- java.lang.Object
-
- io.grpc.util.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).
-
-
Constructor Summary
Constructors Constructor Description CertificateUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.security.PrivateKey
getPrivateKey(java.io.InputStream inputStream)
Generates aPrivateKey
from a PEM file.static java.security.cert.X509Certificate[]
getX509Certificates(java.io.InputStream inputStream)
Generates X509Certificate array from a PEM file.
-
-
-
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 aInputStream
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 aPrivateKey
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 aInputStream
from the private key file- Throws:
java.io.UnsupportedEncodingException
java.io.IOException
java.security.NoSuchAlgorithmException
java.security.spec.InvalidKeySpecException
-
-