Class MtlsHttpTransportFactory (1.58.0)

public class MtlsHttpTransportFactory implements HttpTransportFactory, Serializable

An HttpTransportFactory that creates NetHttpTransport instances configured for mTLS (mutual TLS) using a specific KeyStore containing the client's certificate and private key.

Warning: This class is considered internal and is not intended for direct use by library consumers. Its API and behavior may change without notice.

Inheritance

java.lang.Object > MtlsHttpTransportFactory

Constructors

MtlsHttpTransportFactory()

public MtlsHttpTransportFactory()

Default no-arg constructor creating an instance without a KeyStore (hasKeyStore() == false). This constructor is invoked reflectively by ExternalAccountCredentials.readObject() during deserialization (since transportFactory is transient on ExternalAccountCredentials), after which IdentityPoolCredentials.readObject() reconstructs X509Provider from the serialized certificate configuration and replaces the transport factory with #MtlsHttpTransportFactory(KeyStore). Not intended for direct use; callers configuring mTLS should use #MtlsHttpTransportFactory(KeyStore).

MtlsHttpTransportFactory(KeyStore mtlsKeyStore)

public MtlsHttpTransportFactory(KeyStore mtlsKeyStore)

Constructs a factory for mTLS transports.

Parameter
Name Description
mtlsKeyStore KeyStore

The KeyStore containing the client's X509 certificate and private key. This KeyStore is used for client authentication during the TLS handshake. Must not be null.

Methods

create()

public NetHttpTransport create()

Creates a HttpTransport instance.

Returns
Type Description
com.google.api.client.http.javanet.NetHttpTransport

getKeyStore()

public @Nullable KeyStore getKeyStore()

Returns the KeyStore used by this factory, or null if none was configured.

Returns
Type Description
@org.jspecify.annotations.Nullable java.security.KeyStore

hasKeyStore()

public boolean hasKeyStore()

Returns whether this factory was constructed with a non-null KeyStore containing client certificates for mTLS. A factory created via the no-arg constructor (e.g. during deserialization), with an empty KeyStore, or with a KeyStore containing only trusted CA certificates (without a private key entry and certificate chain) will return false.

Returns
Type Description
boolean