Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor SSLSocket and JSSSocket #1014

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 80 additions & 9 deletions base/src/main/java/org/mozilla/jss/ssl/SSLSocket.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@
import java.util.ArrayList;
import java.util.Collection;

import javax.net.ssl.HandshakeCompletedListener;
import javax.net.ssl.SSLSession;

/**
* SSL client socket.
*/
public class SSLSocket extends java.net.Socket {
public class SSLSocket extends javax.net.ssl.SSLSocket {

/**
*
Expand Down Expand Up @@ -388,7 +391,7 @@ public class SSLSocket extends java.net.Socket {
/**
* For sockets that get created by accept().
*/
SSLSocket() {
protected SSLSocket() {
}

/**
Expand Down Expand Up @@ -1363,13 +1366,13 @@ public void requestClientAuth(boolean b) throws SocketException {
base.requestClientAuth(b);
}

/**
* @deprecated As of JSS 3.0. This method is misnamed. Use
* <code>requestClientAuth</code> instead.
*/
@Deprecated
public void setNeedClientAuth(boolean b) throws SocketException {
base.requestClientAuth(b);
@Override
public void setNeedClientAuth(boolean b) {
try {
base.requestClientAuth(b);
} catch (SocketException e) {
throw new RuntimeException(e);
}
}

/**
Expand Down Expand Up @@ -1644,4 +1647,72 @@ private static native boolean isFipsCipherSuiteNative(int ciphersuite)
* <code>TLS_RSA_WITH_AES_128_CBC_SHA</code>).
*/
public static native int[] getImplementedCipherSuites();

@Override
public String[] getSupportedCipherSuites() {
return null;
}

@Override
public String[] getEnabledCipherSuites() {
return null;
}

@Override
public void setEnabledCipherSuites(String[] suites) {
}

@Override
public String[] getSupportedProtocols() {
return null;
}

@Override
public String[] getEnabledProtocols() {
return null;
}

@Override
public void setEnabledProtocols(String[] protocols) {
}

@Override
public SSLSession getSession() {
return null;
}

@Override
public void addHandshakeCompletedListener(HandshakeCompletedListener listener) {
}

@Override
public void removeHandshakeCompletedListener(HandshakeCompletedListener listener) {
}

@Override
public void startHandshake() throws IOException {
}

@Override
public boolean getNeedClientAuth() {
return false;
}

@Override
public void setWantClientAuth(boolean want) {
}

@Override
public boolean getWantClientAuth() {
return false;
}

@Override
public void setEnableSessionCreation(boolean flag) {
}

@Override
public boolean getEnableSessionCreation() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLParameters;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.X509KeyManager;
import javax.net.ssl.X509TrustManager;

import org.mozilla.jss.pkcs11.PK11Cert;
import org.mozilla.jss.pkcs11.PK11PrivKey;
import org.mozilla.jss.provider.javax.crypto.JSSTrustManager;
import org.mozilla.jss.ssl.SSLSocket;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the goal is to deprecate/remove SSLSocket it is not clear to me the reason of this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed to simplify the transition by minimizing the required changes to existing code. Basically any code that creates the old SSLSocket can be changed to create JSSSocket instead, but the code that uses the SSLSocket instance can automatically use the JSSSocket instance without any changes since it's a subclass, and JSSSocket will inherit the constants defined in SSLSocket too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes will be needed in order to remove SSLSocket but we can do later.


/**
* SSL-enabled socket following the javax.net.ssl.SSLSocket interface.
Expand Down
8 changes: 8 additions & 0 deletions docs/changes/v5.6.0/API-Changes.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,11 @@

The `org.dogtagpki.jss.tomcat.IPasswordStore` has been deprecated.
Use `org.dogtagpki.jss.tomcat.PasswordStore` instead.

== SSLSocket Changes ==

The `org.mozilla.jss.ssl.SSLSocket` has been modified to extend `javax.net.ssl.SSLSocket`.

== JSSSocket Changes ==

The `org.mozilla.jss.ssl.javax.JSSSocket` has been modified to extend `org.mozilla.jss.ssl.SSLSocket`.
Loading