This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new 9265e26d08 Improve test and add no arg constructor
9265e26d08 is described below
commit 9265e26d088cf3b0de3eb2cba4b06dfa89713601
Author: remm <[email protected]>
AuthorDate: Tue Sep 22 15:58:00 2026 +0200
Improve test and add no arg constructor
---
.../apache/tomcat/util/net/SSLHostConfigPreSharedKey.java | 7 +++++++
test/org/apache/catalina/storeconfig/TestStoreConfig.java | 13 ++++++++++---
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/java/org/apache/tomcat/util/net/SSLHostConfigPreSharedKey.java
b/java/org/apache/tomcat/util/net/SSLHostConfigPreSharedKey.java
index 7660490631..c17ce3bf4f 100644
--- a/java/org/apache/tomcat/util/net/SSLHostConfigPreSharedKey.java
+++ b/java/org/apache/tomcat/util/net/SSLHostConfigPreSharedKey.java
@@ -37,6 +37,13 @@ public class SSLHostConfigPreSharedKey implements
Serializable {
private byte[] key;
private MessageDigest digest = MessageDigest.SHA256;
+ /**
+ * Creates a new pre-shared key configuration with default settings.
+ */
+ public SSLHostConfigPreSharedKey() {
+ this(null);
+ }
+
/**
* Creates a new pre-shared key configuration for the given host.
*
diff --git a/test/org/apache/catalina/storeconfig/TestStoreConfig.java
b/test/org/apache/catalina/storeconfig/TestStoreConfig.java
index 0d0c0a3477..df509b4f2e 100644
--- a/test/org/apache/catalina/storeconfig/TestStoreConfig.java
+++ b/test/org/apache/catalina/storeconfig/TestStoreConfig.java
@@ -103,7 +103,9 @@ public class TestStoreConfig extends TomcatBaseTest {
SSLHostConfigPreSharedKey preSharedKey = new
SSLHostConfigPreSharedKey(tc_SSLHostConfig_22);
preSharedKey.setIdentity("test");
preSharedKey.setKey("000102030405060708090a0b0c0d0e0f");
- preSharedKey.setDigest("SHA256");
+ // A non-default digest: storeconfig omits attributes that equal
+ // their default value, and SHA256 is the default digest.
+ preSharedKey.setDigest("SHA384");
tc_SSLHostConfig_22.addPreSharedKey(preSharedKey);
tomcat.getConnector().addSslHostConfig(tc_SSLHostConfig_22);
@@ -169,8 +171,13 @@ public class TestStoreConfig extends TomcatBaseTest {
Assert.assertTrue(serverXmlDump.contains("channelStartOptions"));
Assert.assertTrue(serverXmlDump.contains("SecretKeyCredentialHandler"));
Assert.assertTrue(serverXmlDump.contains("certificateKeystorePassword="));
- Assert.assertTrue(serverXmlDump.contains(
- "<PreSharedKey digest=\"SHA256\" identity=\"test\"
key=\"000102030405060708090a0b0c0d0e0f\""));
+ // The attributes of a stored element wrap at 60 columns, so check
+ // the element and its attributes individually rather than the
+ // whole tag.
+ Assert.assertTrue(serverXmlDump.contains("<PreSharedKey"));
+ Assert.assertTrue(serverXmlDump.contains("digest=\"SHA384\""));
+ Assert.assertTrue(serverXmlDump.contains("identity=\"test\""));
+
Assert.assertTrue(serverXmlDump.contains("key=\"000102030405060708090a0b0c0d0e0f\""));
Assert.assertTrue(serverXmlDump.contains("+TLSv1.1"));
SAXParserFactory.newInstance().newSAXParser().getXMLReader().parse(new
InputSource(new StringReader(serverXmlDump)));
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]