Skip to content

Commit

Permalink
WebClientOptions SSLTrustStore is transient
Browse files Browse the repository at this point in the history
  • Loading branch information
rbri committed Jan 22, 2025
1 parent a19c3de commit 0d7fd31
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

<body>
<release version="4.9.0" date="February xx, 2025" description="Chrome/Edge 132, Firefox 134, BigInt, Bugfixes">
<action type="fix" dev="rbri">
WebClientOptions SSLTrustStore is transient.
</action>
<action type="fix" dev="rbri">
WebClientOptions.Geolocation is serializable now
</action>
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/htmlunit/WebClientOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class WebClientOptions implements Serializable {

private KeyStore sslClientCertificateStore_;
private char[] sslClientCertificatePassword_;
private KeyStore sslTrustStore_;
private transient KeyStore sslTrustStore_;
private String[] sslClientProtocols_;
private String[] sslClientCipherSuites_;

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

/**
* Gets the SSL TrustStore.
* <p>This property is transient (because KeyStore is not serializable)
* @return the SSL TrustStore for insecure SSL connections
*/
public KeyStore getSSLTrustStore() {
Expand Down
18 changes: 18 additions & 0 deletions src/test/java/org/htmlunit/WebClientOptionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
*/
package org.htmlunit;

import java.security.KeyStore;

import javax.net.ssl.SSLContext;

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

assertNull(deserialized.getSSLContext());
}

/**
* @throws Exception if an error occurs
*/
@Test
public void serializationSSLTrustStore() throws Exception {
final WebClientOptions original = new WebClientOptions();

final KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
original.setSSLTrustStore(keyStore);

final byte[] bytes = SerializationUtils.serialize(original);
final WebClientOptions deserialized = (WebClientOptions) SerializationUtils.deserialize(bytes);

assertNull(deserialized.getSSLTrustStore());
}
}

0 comments on commit 0d7fd31

Please sign in to comment.