public class ClientCertificateHandler extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
ClientCertificateHandler.CertificateInfo
Holds response of parseCertificateChain
|
| Constructor and Description |
|---|
ClientCertificateHandler(okhttp3.tls.HandshakeCertificates handshakeCertificates,
Optional<HostnameVerifier> hostnameVerifier)
Creates an instance of
ClientCertificateHandler |
| Modifier and Type | Method and Description |
|---|---|
static InputStream |
filterPEMInputStream(InputStream inStream,
String label)
Filter an InputStream containing PEM sections into another InputStream just containing sections
of a specific PEM block type
|
static Optional<ClientCertificateHandler> |
fromConfiguration(ArtifactCacheBuckConfig config)
Create a new ClientCertificateHandler based on client tls settings in configuration
|
static Optional<ClientCertificateHandler> |
fromConfiguration(ArtifactCacheBuckConfig config,
Optional<HostnameVerifier> hostnameVerifier)
Create a new ClientCertificateHandler based on client tls settings in configuration, with
optional HostnameVerifier to allow for ignoring hostname mismatches in tests
|
okhttp3.tls.HandshakeCertificates |
getHandshakeCertificates() |
Optional<HostnameVerifier> |
getHostnameVerifier() |
static Optional<ClientCertificateHandler.CertificateInfo> |
parseCertificateChain(Optional<Path> certPathOptional,
boolean required)
Parses a PEM encoded X509 certificate chain from a file which may contain non-certificate
sections after the certificate chain.
|
static com.google.common.collect.ImmutableList<X509Certificate> |
parseCertificates(Optional<Path> certPathOptional,
boolean required)
Parses a file containing PEM encoded X509 certificates
|
static Optional<PrivateKey> |
parsePrivateKey(Optional<Path> keyPathOptional,
X509Certificate certificate,
boolean required)
Parse a PEM encoded private key, with the algorithm decided by
certificate |
public ClientCertificateHandler(okhttp3.tls.HandshakeCertificates handshakeCertificates,
Optional<HostnameVerifier> hostnameVerifier)
ClientCertificateHandlerhandshakeCertificates - If non-null, client certificates to use for http connectionshostnameVerifier - Used for testing to bypass hostname verification in integration tests.
Should be null in production use.public static Optional<ClientCertificateHandler> fromConfiguration(ArtifactCacheBuckConfig config)
public static Optional<ClientCertificateHandler> fromConfiguration(ArtifactCacheBuckConfig config, Optional<HostnameVerifier> hostnameVerifier)
public static InputStream filterPEMInputStream(InputStream inStream, String label) throws IOException
inStream - original input streamlabel - PEM block label e.g. CERTIFICATE or PRIVATE KEYinStreamIOExceptionpublic static Optional<PrivateKey> parsePrivateKey(Optional<Path> keyPathOptional, X509Certificate certificate, boolean required)
certificatekeyPathOptional - The path to a PEM encoded PKCS#8 private keycertificate - The corresponding public key. Used to determine key's algorithmrequired - whether to throw or ignore on unset / missing private key{@link - HumanReadableException} on issues with private keypublic static Optional<ClientCertificateHandler.CertificateInfo> parseCertificateChain(Optional<Path> certPathOptional, boolean required)
certPathOptional - The location of the certificate chain filerequired - whether to throw or ignore on unset / missing / expired certificates{@link - HumanReadableException} on issues with certificatepublic static com.google.common.collect.ImmutableList<X509Certificate> parseCertificates(Optional<Path> certPathOptional, boolean required)
certPathOptional - The location of the certificates filerequired - whether to throw or ignore on unset / missing / expired certificates{@link - HumanReadableException} on issues with a certificatepublic okhttp3.tls.HandshakeCertificates getHandshakeCertificates()
public Optional<HostnameVerifier> getHostnameVerifier()