# WebSphere: Missing SSLSocketFactory Class

### Problem <a href="#problem" id="problem"></a>

When using the SeaLights test listener as a javaagent in WebSphere, it fails to connect to our server with `ClassNotFoundException` for `com.ibm.websphere.ssl.protocol.SSLSocketFactory`

{% code overflow="wrap" lineNumbers="true" %}

```
[SEALIGHTS] (...) Error: java.lang.ClassNotFoundException: Cannot find the specified class com.ibm.websphere.ssl.protocol.SSLSocketFactory
java.net.SocketException: java.lang.ClassNotFoundException: Cannot find the specified class com.ibm.websphere.ssl.protocol.SSLSocketFactory
	at javax.net.ssl.DefaultSSLSocketFactory.a(SSLSocketFactory.java:10)
	...
```

{% endcode %}

### Cause <a href="#cause" id="cause"></a>

This is a known issue with WebSphere when SSL is enabled and using a JDK from the WebSphere Application Server (see references below).

When the IBM WebSphere Application Server starts up it sets the security property to the WebSphere default of `com.ibm.websphere.ssl.protocol.SSLSocketFactory` but this class is not visible to the Java agent, thus the `ClassNotFoundException` is raised when trying to open a secured connection to Sealights' servers.

### Solution <a href="#solution" id="solution"></a>

This issue can be resolved by creating a *file* called `sl.java.security` with the following content

{% code overflow="wrap" lineNumbers="true" %}

```
ssl.SocketFactory.provider=
ssl.ServerSocketFactory.provider=
```

{% endcode %}

And then add the following parameter to the JVM arguments of WebSphere alongside our javaagent:&#x20;

{% code overflow="wrap" lineNumbers="true" %}

```
-Djava.security.properties=fullPathTo/sl.java.security
```

{% endcode %}

Another solution is to set WebSphere SSL configuration to use the IBM JSSE implementation by defining the content of `sl.java.security` file as below

{% code overflow="wrap" lineNumbers="true" fullWidth="false" %}

```
ssl.SocketFactory.provider=com.ibm.jsse2.SSLSocketFactoryImpl 
ssl.ServerSocketFactory.provider=com.ibm.jsse2.SSLServerSocketFactoryImpl 
```

{% endcode %}

#### References <a href="#references" id="references"></a>

* <https://www.ibm.com/support/pages/cannot-find-specified-class-comibmwebspheresslprotocolsslsocketfactory>
* <https://www.ibm.com/support/knowledgecenter/en/SSYKE2_8.0.0/com.ibm.java.security.component.80.doc/security-component/jsse2Docs/customization.html>
* <https://backstage.forgerock.com/knowledge/kb/article/a48447600>
* <https://support.contrastsecurity.com/hc/en-us/articles/360040457971-Java-Agent-fails-to-connect-to-Contrast-UI-java-lang-ClassNotFoundException>

### Related articles <a href="#related-articles" id="related-articles"></a>

* [pivotal-cloud-foundry-pcf-support](https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/java-agent/pivotal-cloud-foundry-pcf-support "mention") (Java)
* [nodejs-javascript-heap-out-of-memory](https://docs.sealights.io/knowledgebase/setup-and-configuration/troubleshooting-faq/node-javascript/nodejs-javascript-heap-out-of-memory "mention")
* [testing-frameworks-integration](https://docs.sealights.io/knowledgebase/setup-and-configuration/integrations/testing-frameworks-integration "mention")
* [installing-the-coverage-listener-as-a-jvm-java-agent](https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/java-agent/default-usage-cli/installing-the-coverage-listener-as-a-jvm-java-agent "mention") (Java)
* [cd-agent-for-java-application](https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/cd-agent/cd-agent-for-java-application "mention")
