@@ -101,22 +101,22 @@ public void setUp() throws Exception {
101101
102102 @ Test
103103 public void testHostMLDSA44 () throws Exception {
104- File [] pqcFiles = configureHostMLDSA ("ML-DSA-44" );
105- doTestWithOpenSSLClient (pqcFiles [ 0 ] .getAbsolutePath (), null , null , null );
104+ configureHostMLDSA ("ML-DSA-44" );
105+ doTestWithOpenSSLClient (getCaCertificateFile () .getAbsolutePath (), null , null , null );
106106 }
107107
108108
109109 @ Test
110110 public void testHostMLDSA65 () throws Exception {
111- File [] pqcFiles = configureHostMLDSA ("ML-DSA-65" );
112- doTestWithOpenSSLClient (pqcFiles [ 0 ] .getAbsolutePath (), null , null , null );
111+ configureHostMLDSA ("ML-DSA-65" );
112+ doTestWithOpenSSLClient (getCaCertificateFile () .getAbsolutePath (), null , null , null );
113113 }
114114
115115
116116 @ Test
117117 public void testHostMLDSA87 () throws Exception {
118- File [] pqcFiles = configureHostMLDSA ("ML-DSA-87" );
119- doTestWithOpenSSLClient (pqcFiles [ 0 ] .getAbsolutePath (), null , null , null );
118+ configureHostMLDSA ("ML-DSA-87" );
119+ doTestWithOpenSSLClient (getCaCertificateFile () .getAbsolutePath (), null , null , null );
120120 }
121121
122122 @ Test
@@ -137,7 +137,7 @@ public void testHostECandMLDSA() throws Exception {
137137 public void testHostRSAwithX25519MLKEM768 () throws Exception {
138138 configureHostRSA ();
139139 configureHostWithGroup ("X25519MLKEM768" );
140- doTestWithOpenSSLClient (new File ( TesterSupport . CA_CERT_PEM ).getAbsolutePath (),
140+ doTestWithOpenSSLClient (getCaCertificateFile ( ).getAbsolutePath (),
141141 "X25519MLKEM768" , null , null );
142142 }
143143
@@ -146,53 +146,51 @@ public void testHostRSAwithX25519MLKEM768() throws Exception {
146146 public void testHostRSAwithSecP256r1MLKEM768 () throws Exception {
147147 configureHostRSA ();
148148 configureHostWithGroup ("SecP256r1MLKEM768" );
149- doTestWithOpenSSLClient (new File ( TesterSupport . CA_CERT_PEM ).getAbsolutePath (),
149+ doTestWithOpenSSLClient (getCaCertificateFile ( ).getAbsolutePath (),
150150 "SecP256r1MLKEM768" , null , null );
151151 }
152152
153153 @ Test
154154 public void testHostRSAwithSecP384r1MLKEM1024 () throws Exception {
155155 configureHostRSA ();
156156 configureHostWithGroup ("SecP384r1MLKEM1024" );
157- doTestWithOpenSSLClient (new File ( TesterSupport . CA_CERT_PEM ).getAbsolutePath (),
157+ doTestWithOpenSSLClient (getCaCertificateFile ( ).getAbsolutePath (),
158158 "SecP384r1MLKEM1024" , null , null );
159159 }
160160
161161 @ Test
162162 public void testHostMLDSAwithX25519MLKEM768 () throws Exception {
163- File [] pqcFiles = configureHostMLDSA ("ML-DSA-65" );
163+ configureHostMLDSA ("ML-DSA-65" );
164164 configureHostWithGroup ("X25519MLKEM768" );
165- doTestWithOpenSSLClient (pqcFiles [ 0 ] .getAbsolutePath (), "X25519MLKEM768" , null , null );
165+ doTestWithOpenSSLClient (getCaCertificateFile () .getAbsolutePath (), "X25519MLKEM768" , null , null );
166166 }
167167
168168 @ Test
169169 public void testHostMLDSAwithSecP256r1MLKEM768 () throws Exception {
170- File [] pqcFiles = configureHostMLDSA ("ML-DSA-65" );
170+ configureHostMLDSA ("ML-DSA-65" );
171171 configureHostWithGroup ("SecP256r1MLKEM768" );
172- doTestWithOpenSSLClient (pqcFiles [ 0 ] .getAbsolutePath (), "SecP256r1MLKEM768" , null , null );
172+ doTestWithOpenSSLClient (getCaCertificateFile () .getAbsolutePath (), "SecP256r1MLKEM768" , null , null );
173173 }
174174
175175 @ Test
176176 public void testClientMLDSA () throws Exception {
177177 configureHostRSA ();
178- File [] clientFiles = TesterKeystoreGenerator .generatePQCCertificate ("testuser" , "ML-DSA-65" ,
179- null , null );
178+ File [] clientFiles = getTestUserMLDSA65Files ();
180179 SSLHostConfig sslHostConfig = getTomcatInstance ().getConnector ().findSslHostConfigs ()[0 ];
181180 sslHostConfig .setCertificateVerification ("required" );
182- sslHostConfig .setCaCertificateFile (clientFiles [ 0 ] .getAbsolutePath ());
183- doTestWithOpenSSLClient (new File ( TesterSupport . CA_CERT_PEM ).getAbsolutePath (), null ,
181+ sslHostConfig .setCaCertificateFile (getCaCertificateFile () .getAbsolutePath ());
182+ doTestWithOpenSSLClient (getCaCertificateFile ( ).getAbsolutePath (), null ,
184183 clientFiles [0 ].getAbsolutePath (), clientFiles [1 ].getAbsolutePath ());
185184 }
186185
187186 @ Test
188187 public void testClientMLDSAwithMLDSAServer () throws Exception {
189- File [] serverFiles = configureHostMLDSA ("ML-DSA-65" );
190- File [] clientFiles = TesterKeystoreGenerator .generatePQCCertificate ("testuser" , "ML-DSA-65" ,
191- null , null );
188+ configureHostMLDSA ("ML-DSA-65" );
189+ File [] clientFiles = getTestUserMLDSA65Files ();
192190 SSLHostConfig sslHostConfig = getTomcatInstance ().getConnector ().findSslHostConfigs ()[0 ];
193191 sslHostConfig .setCertificateVerification ("required" );
194- sslHostConfig .setCaCertificateFile (clientFiles [ 0 ] .getAbsolutePath ());
195- doTestWithOpenSSLClient (serverFiles [ 0 ] .getAbsolutePath (), null ,
192+ sslHostConfig .setCaCertificateFile (getCaCertificateFile () .getAbsolutePath ());
193+ doTestWithOpenSSLClient (getCaCertificateFile () .getAbsolutePath (), null ,
196194 clientFiles [0 ].getAbsolutePath (), clientFiles [1 ].getAbsolutePath ());
197195 }
198196
@@ -230,20 +228,43 @@ private void assumePQCSupported() {
230228 }
231229 }
232230
233- private File [] configureHostMLDSA (String algorithm ) throws Exception {
234- File [] pqcFiles = TesterKeystoreGenerator .generatePQCCertificate ("localhost" , algorithm ,
235- new String [] { "localhost" }, null );
231+ private File getCaCertificateFile () {
232+ return new File (TesterSupport .CA_CERT_PEM );
233+ }
234+
235+ private File [] getTestUserMLDSA65Files () {
236+ return new File [] { new File (TesterSupport .TESTUSER_MLDSA_65_CERT_PEM ),
237+ new File (TesterSupport .TESTUSER_MLDSA_65_KEY_PEM ) };
238+ }
239+
240+ private void configureHostMLDSA (String algorithm ) {
241+ String certFile ;
242+ String keyFile ;
243+ switch (algorithm ) {
244+ case "ML-DSA-44" :
245+ certFile = TesterSupport .LOCALHOST_MLDSA_44_CERT_PEM ;
246+ keyFile = TesterSupport .LOCALHOST_MLDSA_44_KEY_PEM ;
247+ break ;
248+ case "ML-DSA-65" :
249+ certFile = TesterSupport .LOCALHOST_MLDSA_65_CERT_PEM ;
250+ keyFile = TesterSupport .LOCALHOST_MLDSA_65_KEY_PEM ;
251+ break ;
252+ case "ML-DSA-87" :
253+ certFile = TesterSupport .LOCALHOST_MLDSA_87_CERT_PEM ;
254+ keyFile = TesterSupport .LOCALHOST_MLDSA_87_KEY_PEM ;
255+ break ;
256+ default :
257+ throw new IllegalArgumentException ("Unknown ML-DSA algorithm [" + algorithm + "]" );
258+ }
236259
237260 Tomcat tomcat = getTomcatInstance ();
238261 Connector connector = tomcat .getConnector ();
239262 SSLHostConfig sslHostConfig = connector .findSslHostConfigs ()[0 ];
240263
241264 SSLHostConfigCertificate cert = new SSLHostConfigCertificate (sslHostConfig , Type .MLDSA );
242- cert .setCertificateFile (pqcFiles [ 0 ] .getAbsolutePath ());
243- cert .setCertificateKeyFile (pqcFiles [ 1 ] .getAbsolutePath ());
265+ cert .setCertificateFile (new File ( certFile ) .getAbsolutePath ());
266+ cert .setCertificateKeyFile (new File ( keyFile ) .getAbsolutePath ());
244267 sslHostConfig .addCertificate (cert );
245-
246- return pqcFiles ;
247268 }
248269
249270 private void configureHostRSA () {
0 commit comments