Skip to content

Commit 17bbfc1

Browse files
chore: add Beta annotation for new mtls functions (#1167)
* feat: support keystore in transport for mtls * fix format * update code * add tests * update test and doc * update names * create keystore from cert and key string * change certAndKey from string to inputstream * add mtls file * Update google-http-client/src/main/java/com/google/api/client/http/javanet/NetHttpTransport.java Co-authored-by: Jeff Ching <chingor@google.com> * Update google-http-client/src/main/java/com/google/api/client/http/javanet/NetHttpTransport.java Co-authored-by: Jeff Ching <chingor@google.com> * Update google-http-client/src/main/java/com/google/api/client/util/SslUtils.java Co-authored-by: Jeff Ching <chingor@google.com> * Update google-http-client/src/main/java/com/google/api/client/util/SslUtils.java Co-authored-by: Jeff Ching <chingor@google.com> * Update google-http-client/src/test/java/com/google/api/client/util/SecurityUtilsTest.java Co-authored-by: Jeff Ching <chingor@google.com> * Update google-http-client/src/main/java/com/google/api/client/util/SslUtils.java Co-authored-by: Jeff Ching <chingor@google.com> * update the code * fix name * chore: add Beta annotation for new mtls functions * update Beta * add since tag Co-authored-by: Jeff Ching <chingor@google.com>
1 parent 51762f2 commit 17bbfc1

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

google-http-client/src/main/java/com/google/api/client/http/HttpTransport.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ public boolean supportsMethod(String method) throws IOException {
133133
* Returns whether the transport is mTLS.
134134
*
135135
* @return boolean indicating if the transport is mTLS.
136+
* @since 1.38
136137
*/
137138
public boolean isMtls() {
138139
return false;

google-http-client/src/main/java/com/google/api/client/http/javanet/NetHttpTransport.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ public NetHttpTransport() {
108108
* @param sslSocketFactory SSL socket factory or {@code null} for the default
109109
* @param hostnameVerifier host name verifier or {@code null} for the default
110110
* @param isMtls Whether the transport is mTLS. Default value is {@code false}
111+
* @since 1.38
111112
*/
112113
NetHttpTransport(
113114
Proxy proxy,
@@ -123,7 +124,7 @@ public NetHttpTransport() {
123124
* @param sslSocketFactory SSL socket factory or {@code null} for the default
124125
* @param hostnameVerifier host name verifier or {@code null} for the default
125126
* @param isMtls Whether the transport is mTLS. Default value is {@code false}
126-
* @since 1.20
127+
* @since 1.38
127128
*/
128129
NetHttpTransport(
129130
ConnectionFactory connectionFactory,
@@ -294,6 +295,7 @@ public Builder trustCertificates(KeyStore trustStore) throws GeneralSecurityExce
294295
}
295296

296297
/**
298+
* {@link Beta} <br>
297299
* Sets the SSL socket factory based on a root certificate trust store and a client certificate
298300
* key store. The client certificate key store will be used to establish mutual TLS.
299301
*
@@ -302,7 +304,9 @@ public Builder trustCertificates(KeyStore trustStore) throws GeneralSecurityExce
302304
* @param mtlsKeyStore key store for client certificate and key to establish mutual TLS. (use
303305
* for example {@link SecurityUtils#createMtlsKeyStore(InputStream)})
304306
* @param mtlsKeyStorePassword password for mtlsKeyStore parameter
307+
* @since 1.38
305308
*/
309+
@Beta
306310
public Builder trustCertificates(
307311
KeyStore trustStore, KeyStore mtlsKeyStore, String mtlsKeyStorePassword)
308312
throws GeneralSecurityException {

google-http-client/src/main/java/com/google/api/client/util/SecurityUtils.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,13 +261,16 @@ public static void loadKeyStoreFromCertificates(
261261
}
262262

263263
/**
264+
* {@link Beta} <br>
264265
* Create a keystore for mutual TLS with the certificate and private key provided.
265266
*
266267
* @param certAndKey Certificate and private key input stream. The stream should contain one
267268
* certificate and one unencrypted private key. If there are multiple certificates, only the
268269
* first certificate will be used.
269270
* @return keystore for mutual TLS.
271+
* @since 1.38
270272
*/
273+
@Beta
271274
public static KeyStore createMtlsKeyStore(InputStream certAndKey)
272275
throws GeneralSecurityException, IOException {
273276
KeyStore keystore = KeyStore.getInstance("JKS");

google-http-client/src/main/java/com/google/api/client/util/SslUtils.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ public static SSLContext initSslContext(
110110
}
111111

112112
/**
113+
* {@link Beta} <br>
113114
* Initializes the SSL context to the trust managers supplied by the trust manager factory for the
114115
* given trust store, and to the key managers supplied by the key manager factory for the given
115116
* key store.
@@ -123,7 +124,9 @@ public static SSLContext initSslContext(
123124
* @param mtlsKeyStorePassword password for mtlsKeyStore parameter
124125
* @param keyManagerFactory key manager factory (for example {@link
125126
* #getDefaultKeyManagerFactory()})
127+
* @since 1.38
126128
*/
129+
@Beta
127130
public static SSLContext initSslContext(
128131
SSLContext sslContext,
129132
KeyStore trustStore,

0 commit comments

Comments
 (0)