|
8 | 8 |
|
9 | 9 | package org.elasticsearch.cloud.gce;
|
10 | 10 |
|
| 11 | +import com.google.api.client.googleapis.GoogleUtils; |
11 | 12 | import com.google.api.client.googleapis.compute.ComputeCredential;
|
12 |
| -import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport; |
13 | 13 | import com.google.api.client.http.GenericUrl;
|
14 | 14 | import com.google.api.client.http.HttpHeaders;
|
15 | 15 | import com.google.api.client.http.HttpRequest;
|
|
19 | 19 | import com.google.api.client.http.javanet.NetHttpTransport;
|
20 | 20 | import com.google.api.client.json.JsonFactory;
|
21 | 21 | import com.google.api.client.json.jackson2.JacksonFactory;
|
| 22 | +import com.google.api.client.util.SecurityUtils; |
22 | 23 | import com.google.api.services.compute.Compute;
|
23 | 24 | import com.google.api.services.compute.model.Instance;
|
24 | 25 | import com.google.api.services.compute.model.InstanceList;
|
|
36 | 37 |
|
37 | 38 | import java.io.IOException;
|
38 | 39 | import java.security.GeneralSecurityException;
|
| 40 | +import java.security.KeyStore; |
39 | 41 | import java.util.ArrayList;
|
40 | 42 | import java.util.Collection;
|
41 | 43 | import java.util.Collections;
|
@@ -173,7 +175,12 @@ private static boolean headerContainsMetadataFlavor(HttpResponse response) {
|
173 | 175 | protected synchronized HttpTransport getGceHttpTransport() throws GeneralSecurityException, IOException {
|
174 | 176 | if (gceHttpTransport == null) {
|
175 | 177 | if (validateCerts) {
|
176 |
| - gceHttpTransport = GoogleNetHttpTransport.newTrustedTransport(); |
| 178 | + // Manually load the certificates in the jks format instead of the default p12 which is not compatible with FIPS. |
| 179 | + KeyStore certTrustStore = SecurityUtils.getJavaKeyStore(); |
| 180 | + try (var is = GoogleUtils.class.getResourceAsStream("google.jks")) { |
| 181 | + SecurityUtils.loadKeyStore(certTrustStore, is, "notasecret"); |
| 182 | + } |
| 183 | + gceHttpTransport = new NetHttpTransport.Builder().trustCertificates(certTrustStore).build(); |
177 | 184 | } else {
|
178 | 185 | // this is only used for testing - alternative we could use the defaul keystore but this requires special configs too..
|
179 | 186 | gceHttpTransport = new NetHttpTransport.Builder().doNotValidateCertificate().build();
|
|
0 commit comments