File tree Expand file tree Collapse file tree 3 files changed +23
-9
lines changed
gax-grpc/src/main/java/com/google/api/gax/grpc
gax-httpjson/src/main/java/com/google/api/gax/httpjson
gax/src/main/java/com/google/api/gax/rpc Expand file tree Collapse file tree 3 files changed +23
-9
lines changed Original file line number Diff line number Diff line change @@ -1300,6 +1300,9 @@ public InstantiatingGrpcChannelProvider build() {
13001300 LOG .log (
13011301 Level .WARNING ,
13021302 "DefaultMtlsProviderFactory encountered unexpected IOException: " + e .getMessage ());
1303+ LOG .log (
1304+ Level .WARNING ,
1305+ "mTLS configuration was detected on the device, but mTLS failed to initialize. Falling back to non-mTLS channel." );
13031306 }
13041307 }
13051308 }
Original file line number Diff line number Diff line change @@ -356,6 +356,9 @@ public InstantiatingHttpJsonChannelProvider build() {
356356 LOG .log (
357357 Level .WARNING ,
358358 "DefaultMtlsProviderFactory encountered unexpected IOException: " + e .getMessage ());
359+ LOG .log (
360+ Level .WARNING ,
361+ "mTLS configuration was detected on the device, but mTLS failed to initialize. Falling back to non-mTLS channel." );
359362 }
360363 }
361364 }
Original file line number Diff line number Diff line change @@ -292,17 +292,25 @@ private String determineEndpoint() throws IOException {
292292 ? CertificateBasedAccess .createWithSystemEnv ()
293293 : certificateBasedAccess ();
294294 MtlsProvider mtlsProvider = mtlsProvider ();
295- if (mtlsProvider == null ) {
296- try {
297- mtlsProvider = DefaultMtlsProviderFactory .create ();
298- } catch (CertificateSourceUnavailableException e ) {
299- // This is okay. Leave mtlsProvider as null;
300- } catch (IOException e ) {
301- LOG .log (
302- Level .WARNING ,
303- "DefaultMtlsProviderFactory encountered unexpected IOException: " + e .getMessage ());
295+
296+ // Only attempt to create a default MtlsProvider if client certificate usage is enabled.
297+ if (certificateBasedAccess .useMtlsClientCertificate ()) {
298+ if (mtlsProvider == null ) {
299+ try {
300+ mtlsProvider = DefaultMtlsProviderFactory .create ();
301+ } catch (CertificateSourceUnavailableException e ) {
302+ // This is okay. Leave mtlsProvider as null;
303+ } catch (IOException e ) {
304+ LOG .log (
305+ Level .WARNING ,
306+ "DefaultMtlsProviderFactory encountered unexpected IOException: " + e .getMessage ());
307+ LOG .log (
308+ Level .WARNING ,
309+ "mTLS configuration was detected on the device, but mTLS failed to initialize. Falling back to non-mTLS channel." );
310+ }
304311 }
305312 }
313+
306314 // TransportChannelProvider's endpoint will override the ClientSettings' endpoint
307315 String customEndpoint =
308316 transportChannelProviderEndpoint () == null
You can’t perform that action at this time.
0 commit comments