Skip to content

Commit 0d7fd31

Browse files
committed
WebClientOptions SSLTrustStore is transient
1 parent a19c3de commit 0d7fd31

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

src/changes/changes.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
<body>
1010
<release version="4.9.0" date="February xx, 2025" description="Chrome/Edge 132, Firefox 134, BigInt, Bugfixes">
11+
<action type="fix" dev="rbri">
12+
WebClientOptions SSLTrustStore is transient.
13+
</action>
1114
<action type="fix" dev="rbri">
1215
WebClientOptions.Geolocation is serializable now
1316
</action>

src/main/java/org/htmlunit/WebClientOptions.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public class WebClientOptions implements Serializable {
5555

5656
private KeyStore sslClientCertificateStore_;
5757
private char[] sslClientCertificatePassword_;
58-
private KeyStore sslTrustStore_;
58+
private transient KeyStore sslTrustStore_;
5959
private String[] sslClientProtocols_;
6060
private String[] sslClientCipherSuites_;
6161

@@ -541,6 +541,7 @@ public String getSSLInsecureProtocol() {
541541
/**
542542
* Sets the SSL server certificate trust store. All server certificates will be validated against
543543
* this trust store.
544+
* <p>This property is transient (because KeyStore is not serializable)
544545
* <p>
545546
* The needed parameters are used to construct a {@link java.security.KeyStore}.
546547
*
@@ -564,6 +565,7 @@ void setSSLTrustStore(final KeyStore keyStore) {
564565

565566
/**
566567
* Gets the SSL TrustStore.
568+
* <p>This property is transient (because KeyStore is not serializable)
567569
* @return the SSL TrustStore for insecure SSL connections
568570
*/
569571
public KeyStore getSSLTrustStore() {

src/test/java/org/htmlunit/WebClientOptionsTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
*/
1515
package org.htmlunit;
1616

17+
import java.security.KeyStore;
18+
1719
import javax.net.ssl.SSLContext;
1820

1921
import org.apache.commons.lang3.SerializationUtils;
@@ -108,4 +110,20 @@ public void serializationSSLContextProvider() throws Exception {
108110

109111
assertNull(deserialized.getSSLContext());
110112
}
113+
114+
/**
115+
* @throws Exception if an error occurs
116+
*/
117+
@Test
118+
public void serializationSSLTrustStore() throws Exception {
119+
final WebClientOptions original = new WebClientOptions();
120+
121+
final KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
122+
original.setSSLTrustStore(keyStore);
123+
124+
final byte[] bytes = SerializationUtils.serialize(original);
125+
final WebClientOptions deserialized = (WebClientOptions) SerializationUtils.deserialize(bytes);
126+
127+
assertNull(deserialized.getSSLTrustStore());
128+
}
111129
}

0 commit comments

Comments
 (0)