Class TlsConfigHelper
java.lang.Object
io.opentelemetry.exporter.internal.TlsConfigHelper
Utility class to help with management of TLS related components. TLS config consists
keyManager
, trustManager
, which combine to form sslContext
. These components
can be configured via higher level APIs (setTrustManagerFromCerts(byte[])
and setKeyManagerFromCerts(byte[], byte[])
) which parse keys in PEM format, or the lower level API
setSslContext(SSLContext, X509TrustManager)
in which the components are directly set,
but NOT both. Attempts to reconfigure components which have already been configured throw IllegalStateException
. Consumers access components via any combination of getKeyManager()
, getTrustManager()
, and getSslContext()
.
This class is internal and is hence not for public use. Its APIs are unstable and can change at any time.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate X509KeyManager
private SSLContext
private X509TrustManager
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncopy()
Return a shallow copy of this instance.Get theX509KeyManager
.Get theSSLContext
.Get theX509TrustManager
.void
setKeyManagerFromCerts
(byte[] privateKeyPem, byte[] certificatePem) Configure theX509KeyManager
from the given private key and certificate, both in PEM format.void
setSslContext
(SSLContext sslContext, X509TrustManager trustManager) Configure theSSLContext
andX509TrustManager
.void
setTrustManagerFromCerts
(byte[] trustedCertsPem) Configure theX509TrustManager
from the given cert content.
-
Field Details
-
keyManager
-
trustManager
-
sslContext
-
-
Constructor Details
-
TlsConfigHelper
public TlsConfigHelper()
-
-
Method Details
-
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
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
Get theX509KeyManager
. -
getTrustManager
Get theX509TrustManager
. -
getSslContext
Get theSSLContext
. -
copy
Return a shallow copy of this instance.
-