Skip to content

Commit

Permalink
Fix MongoDBIO ignore SSL KeyStore not initialized (#29403)
Browse files Browse the repository at this point in the history
Co-authored-by: Yi Hu <yathu@google.com>
  • Loading branch information
tvalentyn and Abacn committed Nov 11, 2023
1 parent 8b6ae4a commit d9248c8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ static SSLContext ignoreSSLCertificate() {
InputStream inputStream = classLoader.getResourceAsStream("resources/.keystore");
if (inputStream != null) {
LOG.info("Found keystore in classpath 'resources/.keystore'. Loading...");
ks.load(inputStream, "changeit".toCharArray());
} else {
LOG.info(
"Unable to find keystore under 'resources/.keystore' in the classpath. "
+ "Continuing with an empty keystore.");
}
ks.load(inputStream, "changeit".toCharArray());
KeyManagerFactory kmf =
KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
kmf.init(ks, "changeit".toCharArray());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.beam.sdk.io.mongodb;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/** Test on the MongoDbIO SSLUtils. */
@RunWith(JUnit4.class)
public class SSLUtilsTest {
@Test
public void testIgnoreSSLCertificate() {
// smoke test
SSLUtils.ignoreSSLCertificate();
}
}

0 comments on commit d9248c8

Please sign in to comment.