Package com.google.auth.mtls
Class X509Provider
java.lang.Object
com.google.auth.mtls.X509Provider
- All Implemented Interfaces:
MtlsProvider
This class implements
MtlsProvider for the Google Auth library transport layer via WorkloadCertificateConfiguration. This is only meant to be used internally by Google Cloud
libraries, and the public facing methods may be changed without notice, and have no guarantee of
backwards compatibility.-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new X.509 provider that will check the environment variable path and the well known Gcloud certificate configuration location.X509Provider(EnvironmentProvider envProvider, PropertyProvider propProvider, String certConfigPathOverride) Creates an X509 provider with an override path for the certificate configuration, bypassing the normal checks for the well known certificate configuration file path and environment variable.X509Provider(String certConfigPathOverride) Creates an X509 provider with an override path for the certificate configuration. -
Method Summary
Modifier and TypeMethodDescriptionFinds the certificate configuration file, then builds a Keystore using the X.509 certificate and private key pointed to by the configuration.booleanReturns true if the X509 mTLS provider is available.
-
Constructor Details
-
X509Provider
@InternalApi public X509Provider(EnvironmentProvider envProvider, PropertyProvider propProvider, String certConfigPathOverride) Creates an X509 provider with an override path for the certificate configuration, bypassing the normal checks for the well known certificate configuration file path and environment variable. This is meant for internal Google Cloud usage and behavior may be changed without warning.- Parameters:
envProvider- environment provider used for environment variablespropProvider- property provider used for system propertiescertConfigPathOverride- the path to read the certificate configuration from.
-
X509Provider
Creates an X509 provider with an override path for the certificate configuration.- Parameters:
certConfigPathOverride- the path to read the certificate configuration from.
-
X509Provider
public X509Provider()Creates a new X.509 provider that will check the environment variable path and the well known Gcloud certificate configuration location. This is meant for internal Google Cloud usage and behavior may be changed without warning.
-
-
Method Details
-
getKeyStore
Finds the certificate configuration file, then builds a Keystore using the X.509 certificate and private key pointed to by the configuration. This will check the following locations in order.- The certificate config override path, if set.
- The path pointed to by the "GOOGLE_API_CERTIFICATE_CONFIG" environment variable
- The well known gcloud location for the certificate configuration file.
- Specified by:
getKeyStorein interfaceMtlsProvider- Returns:
- a KeyStore containing the X.509 certificate specified by the certificate configuration.
- Throws:
CertificateSourceUnavailableException- if the certificate source is unavailable (ex. missing configuration file)IOException- if a general I/O error occurs while creating the KeyStore
-
isAvailable
Returns true if the X509 mTLS provider is available.- Specified by:
isAvailablein interfaceMtlsProvider- Throws:
IOException- if a general I/O error occurs while determining availability.
-