File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
interop-testing/src/test/java/io/grpc/testing/integration
testing/src/main/java/io/grpc/testing Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -88,8 +88,7 @@ protected ManagedChannel createChannel() {
8888 .overrideAuthority (GrpcUtil .authorityFromHostAndPort (
8989 TestUtils .TEST_SERVER_HOST , serverPort ));
9090 try {
91- builder .sslSocketFactory (TestUtils .newSslSocketFactoryForCa (
92- TestUtils .loadCert ("ca.pem" )));
91+ builder .sslSocketFactory (TestUtils .newSslSocketFactoryForCa (TestUtils .loadCert ("ca.pem" )));
9392 } catch (Exception e ) {
9493 throw new RuntimeException (e );
9594 }
Original file line number Diff line number Diff line change @@ -217,11 +217,23 @@ public static File loadCert(String name) throws IOException {
217217 * Creates an SSLSocketFactory which contains {@code certChainFile} as its only root certificate.
218218 */
219219 public static SSLSocketFactory newSslSocketFactoryForCa (File certChainFile ) throws Exception {
220+ InputStream is = new FileInputStream (certChainFile );
221+ try {
222+ return newSslSocketFactoryForCa (is );
223+ } finally {
224+ is .close ();
225+ }
226+ }
227+
228+ /**
229+ * Creates an SSLSocketFactory which contains {@code certChainFile} as its only root certificate.
230+ */
231+ public static SSLSocketFactory newSslSocketFactoryForCa (InputStream certChain ) throws Exception {
220232 KeyStore ks = KeyStore .getInstance ("JKS" );
221233 ks .load (null , null );
222234 CertificateFactory cf = CertificateFactory .getInstance ("X.509" );
223235 X509Certificate cert = (X509Certificate ) cf .generateCertificate (
224- new BufferedInputStream (new FileInputStream ( certChainFile ) ));
236+ new BufferedInputStream (certChain ));
225237 X500Principal principal = cert .getSubjectX500Principal ();
226238 ks .setCertificateEntry (principal .getName ("RFC2253" ), cert );
227239
You can’t perform that action at this time.
0 commit comments