Package io.grpc
Class TlsServerCredentials.Builder
- java.lang.Object
-
- io.grpc.TlsServerCredentials.Builder
-
- Enclosing class:
- TlsServerCredentials
public static final class TlsServerCredentials.Builder extends java.lang.ObjectBuilder forTlsServerCredentials.
-
-
Field Summary
Fields Modifier and Type Field Description private byte[]certificateChainprivate TlsServerCredentials.ClientAuthclientAuthprivate booleanfakeFeatureprivate java.util.List<javax.net.ssl.KeyManager>keyManagersprivate byte[]privateKeyprivate java.lang.StringprivateKeyPasswordprivate byte[]rootCertificatesprivate java.util.List<javax.net.ssl.TrustManager>trustManagers
-
Constructor Summary
Constructors Modifier Constructor Description privateBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ServerCredentialsbuild()Construct the credentials.private voidclearKeyManagers()private voidclearTrustManagers()TlsServerCredentials.BuilderclientAuth(TlsServerCredentials.ClientAuth clientAuth)Indicates whether the server should expect a client's identity.TlsServerCredentials.BuilderkeyManager(java.io.File certChain, java.io.File privateKey)Use the provided certificate chain and private key as the server's identity.TlsServerCredentials.BuilderkeyManager(java.io.File certChain, java.io.File privateKey, java.lang.String privateKeyPassword)Use the provided certificate chain and possibly-encrypted private key as the server's identity.TlsServerCredentials.BuilderkeyManager(java.io.InputStream certChain, java.io.InputStream privateKey)Use the provided certificate chain and private key as the server's identity.TlsServerCredentials.BuilderkeyManager(java.io.InputStream certChain, java.io.InputStream privateKey, java.lang.String privateKeyPassword)Use the provided certificate chain and possibly-encrypted private key as the server's identity.TlsServerCredentials.BuilderkeyManager(javax.net.ssl.KeyManager... keyManagers)Have the provided key manager select the server's identity.TlsServerCredentials.BuilderrequireFakeFeature()RequiresTlsServerCredentials.Feature.FAKEto be understood.TlsServerCredentials.BuildertrustManager(java.io.File rootCerts)Use the provided root certificates to verify the client's identity instead of the system's default.TlsServerCredentials.BuildertrustManager(java.io.InputStream rootCerts)Use the provided root certificates to verify the client's identity instead of the system's default.TlsServerCredentials.BuildertrustManager(javax.net.ssl.TrustManager... trustManagers)Have the provided trust manager verify the client's identity instead of the system's default.
-
-
-
Field Detail
-
fakeFeature
private boolean fakeFeature
-
certificateChain
private byte[] certificateChain
-
privateKey
private byte[] privateKey
-
privateKeyPassword
private java.lang.String privateKeyPassword
-
keyManagers
private java.util.List<javax.net.ssl.KeyManager> keyManagers
-
clientAuth
private TlsServerCredentials.ClientAuth clientAuth
-
rootCertificates
private byte[] rootCertificates
-
trustManagers
private java.util.List<javax.net.ssl.TrustManager> trustManagers
-
-
Method Detail
-
requireFakeFeature
public TlsServerCredentials.Builder requireFakeFeature()
RequiresTlsServerCredentials.Feature.FAKEto be understood. For use in testing consumers of this credential.
-
keyManager
public TlsServerCredentials.Builder keyManager(java.io.File certChain, java.io.File privateKey) throws java.io.IOException
Use the provided certificate chain and private key as the server's identity. Generally they should be PEM-encoded and the key is an unencrypted PKCS#8 key (file headers have "BEGIN CERTIFICATE" and "BEGIN PRIVATE KEY").- Throws:
java.io.IOException
-
keyManager
public TlsServerCredentials.Builder keyManager(java.io.File certChain, java.io.File privateKey, java.lang.String privateKeyPassword) throws java.io.IOException
Use the provided certificate chain and possibly-encrypted private key as the server's identity. Generally they should be PEM-encoded and the key is a PKCS#8 key. If the private key is unencrypted, then password must benull.- Throws:
java.io.IOException
-
keyManager
public TlsServerCredentials.Builder keyManager(java.io.InputStream certChain, java.io.InputStream privateKey) throws java.io.IOException
Use the provided certificate chain and private key as the server's identity. Generally they should be PEM-encoded and the key is an unencrypted PKCS#8 key (file headers have "BEGIN CERTIFICATE" and "BEGIN PRIVATE KEY").- Throws:
java.io.IOException
-
keyManager
public TlsServerCredentials.Builder keyManager(java.io.InputStream certChain, java.io.InputStream privateKey, java.lang.String privateKeyPassword) throws java.io.IOException
Use the provided certificate chain and possibly-encrypted private key as the server's identity. Generally they should be PEM-encoded and the key is a PKCS#8 key. If the private key is unencrypted, then password must benull.- Throws:
java.io.IOException
-
keyManager
public TlsServerCredentials.Builder keyManager(javax.net.ssl.KeyManager... keyManagers)
Have the provided key manager select the server's identity. Although multiple are allowed, only the first instance implementing a particular interface is used. So generally there will just be a single entry and it implementsX509KeyManager.
-
clearKeyManagers
private void clearKeyManagers()
-
clientAuth
public TlsServerCredentials.Builder clientAuth(TlsServerCredentials.ClientAuth clientAuth)
Indicates whether the server should expect a client's identity. Must not benull. Defaults toTlsServerCredentials.ClientAuth.NONE.
-
trustManager
public TlsServerCredentials.Builder trustManager(java.io.File rootCerts) throws java.io.IOException
Use the provided root certificates to verify the client's identity instead of the system's default. Generally they should be PEM-encoded with all the certificates concatenated together (file header has "BEGIN CERTIFICATE", and would occur once per certificate).- Throws:
java.io.IOException
-
trustManager
public TlsServerCredentials.Builder trustManager(java.io.InputStream rootCerts) throws java.io.IOException
Use the provided root certificates to verify the client's identity instead of the system's default. Generally they should be PEM-encoded with all the certificates concatenated together (file header has "BEGIN CERTIFICATE", and would occur once per certificate).- Throws:
java.io.IOException
-
trustManager
public TlsServerCredentials.Builder trustManager(javax.net.ssl.TrustManager... trustManagers)
Have the provided trust manager verify the client's identity instead of the system's default. Although multiple are allowed, only the first instance implementing a particular interface is used. So generally there will just be a single entry and it implementsX509TrustManager.
-
clearTrustManagers
private void clearTrustManagers()
-
build
public ServerCredentials build()
Construct the credentials.
-
-