Skip to content

Commit aaedfbb

Browse files
committed
WebClientOptions sslClientCertificateStore is transient
1 parent 2d8e709 commit aaedfbb

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

src/changes/changes.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
</properties>
88

99
<body>
10+
<release version="4.10.0" date="February xx, 2025" description="Bugfixes">
11+
<action type="fix" dev="rbri">
12+
WebClientOptions sslClientCertificateStore is transient.
13+
</action>
14+
</release>
15+
16+
1017
<release version="4.9.0" date="January 22, 2025" description="Chrome/Edge 132, Firefox 134, BigInt, Bugfixes">
1118
<action type="fix" dev="rbri">
1219
WebClientOptions SSLTrustStore is transient.
@@ -32,6 +39,7 @@
3239
</action>
3340
</release>
3441

42+
3543
<release version="4.8.0" date="January 12, 2025" description="Bugfixes, css colors, less dependencies, improved javascript support">
3644
<action type="add" dev="rbri">
3745
cssparser: support plain color definitions with var/calc.

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class WebClientOptions implements Serializable {
5353
private boolean isRedirectEnabled_ = true;
5454
private File tempFileDirectory_;
5555

56-
private KeyStore sslClientCertificateStore_;
56+
private transient KeyStore sslClientCertificateStore_;
5757
private char[] sslClientCertificatePassword_;
5858
private transient KeyStore sslTrustStore_;
5959
private String[] sslClientProtocols_;
@@ -188,6 +188,7 @@ public boolean isRedirectEnabled() {
188188
* In some cases the impl seems to pick old certificates from the {@link KeyStore}. To avoid
189189
* that, wrap your {@link KeyStore} inside your own {@link KeyStore} impl and filter out outdated
190190
* certificates.
191+
* <p>This property is transient (because KeyStore is not serializable)
191192
*
192193
* @param keyStore {@link KeyStore} to use
193194
* @param keyStorePassword the keystore password
@@ -205,6 +206,7 @@ public void setSSLClientCertificateKeyStore(final KeyStore keyStore, final char[
205206
* "sun.security.ssl.allowUnsafeRenegotiation" to true, as hinted in
206207
* <a href="http://www.oracle.com/technetwork/java/javase/documentation/tlsreadme2-176330.html">
207208
* TLS Renegotiation Issue</a>.
209+
* <p>This property is transient (because KeyStore is not serializable)
208210
*
209211
* @param keyStoreUrl the URL which locates the certificate {@link KeyStore}
210212
* @param keyStorePassword the certificate {@link KeyStore} password
@@ -253,6 +255,8 @@ public void setSSLClientCertificateKeyStore(final InputStream keyStoreInputStrea
253255

254256
/**
255257
* Gets the SSLClientCertificateStore.
258+
* <p>This property is transient (because KeyStore is not serializable)
259+
*
256260
* @return the KeyStore for use on SSL connections
257261
*/
258262
public KeyStore getSSLClientCertificateStore() {
@@ -542,8 +546,7 @@ public String getSSLInsecureProtocol() {
542546
* Sets the SSL server certificate trust store. All server certificates will be validated against
543547
* this trust store.
544548
* <p>This property is transient (because KeyStore is not serializable)
545-
* <p>
546-
* The needed parameters are used to construct a {@link java.security.KeyStore}.
549+
* <p>The needed parameters are used to construct a {@link java.security.KeyStore}.
547550
*
548551
* @param sslTrustStoreUrl the URL which locates the trust store
549552
* @param sslTrustStorePassword the trust store password

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import org.apache.commons.lang3.SerializationUtils;
2222
import org.htmlunit.junit.BrowserRunner;
23+
import org.junit.Assert;
2324
import org.junit.Test;
2425
import org.junit.runner.RunWith;
2526

@@ -126,4 +127,21 @@ public void serializationSSLTrustStore() throws Exception {
126127

127128
assertNull(deserialized.getSSLTrustStore());
128129
}
130+
131+
/**
132+
* @throws Exception if an error occurs
133+
*/
134+
@Test
135+
public void sslClientCertificateStore() throws Exception {
136+
final WebClientOptions original = new WebClientOptions();
137+
138+
final KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
139+
original.setSSLClientCertificateKeyStore(keyStore, "secret".toCharArray());
140+
141+
final byte[] bytes = SerializationUtils.serialize(original);
142+
final WebClientOptions deserialized = (WebClientOptions) SerializationUtils.deserialize(bytes);
143+
144+
assertNull(deserialized.getSSLClientCertificateStore());
145+
Assert.assertArrayEquals("secret".toCharArray(), deserialized.getSSLClientCertificatePassword());
146+
}
129147
}

0 commit comments

Comments
 (0)