From 06dd73534271874eff008b8d3027f4ce49b136b3 Mon Sep 17 00:00:00 2001 From: John Jiang Date: Wed, 3 Jan 2024 08:27:42 +0000 Subject: [PATCH] 8322766: Micro bench SSLHandshake should use default algorithms Reviewed-by: djelinski --- .../org/openjdk/bench/java/security/SSLHandshake.java | 9 +++++---- .../openjdk/bench/java/security/TestCertificates.java | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/test/micro/org/openjdk/bench/java/security/SSLHandshake.java b/test/micro/org/openjdk/bench/java/security/SSLHandshake.java index 67e51e9532d..62c45045585 100644 --- a/test/micro/org/openjdk/bench/java/security/SSLHandshake.java +++ b/test/micro/org/openjdk/bench/java/security/SSLHandshake.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -80,11 +80,12 @@ public class SSLHandshake { KeyStore ks = TestCertificates.getKeyStore(); KeyStore ts = TestCertificates.getTrustStore(); - KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); + KeyManagerFactory kmf = KeyManagerFactory.getInstance( + KeyManagerFactory.getDefaultAlgorithm()); kmf.init(ks, new char[0]); - TrustManagerFactory tmf = - TrustManagerFactory.getInstance("SunX509"); + TrustManagerFactory tmf = TrustManagerFactory.getInstance( + TrustManagerFactory.getDefaultAlgorithm()); tmf.init(ts); SSLContext sslCtx = SSLContext.getInstance(tlsVersion); diff --git a/test/micro/org/openjdk/bench/java/security/TestCertificates.java b/test/micro/org/openjdk/bench/java/security/TestCertificates.java index 50d8401c070..752f0442a93 100644 --- a/test/micro/org/openjdk/bench/java/security/TestCertificates.java +++ b/test/micro/org/openjdk/bench/java/security/TestCertificates.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -115,12 +115,12 @@ class TestCertificates { private TestCertificates() {} public static KeyStore getKeyStore() throws GeneralSecurityException, IOException { - KeyStore result = KeyStore.getInstance("JKS"); + KeyStore result = KeyStore.getInstance(KeyStore.getDefaultType()); result.load(null, null); CertificateFactory cf = CertificateFactory.getInstance("X.509"); Certificate serverCert = cf.generateCertificate( new ByteArrayInputStream( - TestCertificates.SERVER_CERT.getBytes(StandardCharsets.ISO_8859_1))); + SERVER_CERT.getBytes(StandardCharsets.ISO_8859_1))); Certificate caCert = cf.generateCertificate( new ByteArrayInputStream( CA_CERT.getBytes(StandardCharsets.ISO_8859_1))); @@ -135,7 +135,7 @@ class TestCertificates { } public static KeyStore getTrustStore() throws GeneralSecurityException, IOException { - KeyStore result = KeyStore.getInstance("JKS"); + KeyStore result = KeyStore.getInstance(KeyStore.getDefaultType()); result.load(null, null); CertificateFactory cf = CertificateFactory.getInstance("X.509"); Certificate rootcaCert = cf.generateCertificate(