Class TlsConfigHelper
- java.lang.Object
-
- io.opentelemetry.exporter.internal.TlsConfigHelper
-
public class TlsConfigHelper extends java.lang.Object
Utility class to help with management of TLS related components. TLS config consistskeyManager
,trustManager
, which combine to formsslContext
. These components can be configured via higher level APIs (setTrustManagerFromCerts(byte[])
andsetKeyManagerFromCerts(byte[], byte[])
) which parse keys in PEM format, or the lower level APIsetSslContext(SSLContext, X509TrustManager)
in which the components are directly set, but NOT both. Attempts to reconfigure components which have already been configured throwIllegalStateException
. Consumers access components via any combination ofgetKeyManager()
,getTrustManager()
, andgetSslContext()
.This class is internal and is hence not for public use. Its APIs are unstable and can change at any time.
-
-
Field Summary
Fields Modifier and Type Field Description private javax.net.ssl.X509KeyManager
keyManager
private javax.net.ssl.SSLContext
sslContext
private javax.net.ssl.X509TrustManager
trustManager
-
Constructor Summary
Constructors Constructor Description TlsConfigHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TlsConfigHelper
copy()
Return a shallow copy of this instance.javax.net.ssl.X509KeyManager
getKeyManager()
Get theX509KeyManager
.javax.net.ssl.SSLContext
getSslContext()
Get theSSLContext
.javax.net.ssl.X509TrustManager
getTrustManager()
Get theX509TrustManager
.void
setKeyManagerFromCerts(byte[] privateKeyPem, byte[] certificatePem)
Configure theX509KeyManager
from the given private key and certificate, both in PEM format.void
setSslContext(javax.net.ssl.SSLContext sslContext, javax.net.ssl.X509TrustManager trustManager)
Configure theSSLContext
andX509TrustManager
.void
setTrustManagerFromCerts(byte[] trustedCertsPem)
Configure theX509TrustManager
from the given cert content.
-
-
-
Method Detail
-
setTrustManagerFromCerts
public void setTrustManagerFromCerts(byte[] trustedCertsPem)
Configure theX509TrustManager
from the given cert content.Must not be called multiple times, or if
setSslContext(SSLContext, X509TrustManager)
has been previously called.- Parameters:
trustedCertsPem
- Certificate in PEM format.
-
setKeyManagerFromCerts
public void setKeyManagerFromCerts(byte[] privateKeyPem, byte[] certificatePem)
Configure theX509KeyManager
from the given private key and certificate, both in PEM format.Must not be called multiple times, or if
setSslContext(SSLContext, X509TrustManager)
has been previously called.- Parameters:
privateKeyPem
- Private key content in PEM format.certificatePem
- Certificate content in PEM format.
-
setSslContext
public void setSslContext(javax.net.ssl.SSLContext sslContext, javax.net.ssl.X509TrustManager trustManager)
Configure theSSLContext
andX509TrustManager
.Must not be called multiple times, or if
setTrustManagerFromCerts(byte[])
orsetKeyManagerFromCerts(byte[], byte[])
has been previously called.- Parameters:
sslContext
- the SSL context.trustManager
- the trust manager.
-
getKeyManager
@Nullable public javax.net.ssl.X509KeyManager getKeyManager()
Get theX509KeyManager
.
-
getTrustManager
@Nullable public javax.net.ssl.X509TrustManager getTrustManager()
Get theX509TrustManager
.
-
getSslContext
@Nullable public javax.net.ssl.SSLContext getSslContext()
Get theSSLContext
.
-
copy
public TlsConfigHelper copy()
Return a shallow copy of this instance.
-
-