Skip to content

Commit 0019a3f

Browse files
committed
Remove uses of classes in the 'javax.security.cert' package
1 parent 15e5454 commit 0019a3f

File tree

7 files changed

+4
-101
lines changed

7 files changed

+4
-101
lines changed

core/src/main/java/io/undertow/protocols/ssl/SNISSLEngine.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import javax.net.ssl.SSLPeerUnverifiedException;
3434
import javax.net.ssl.SSLSession;
3535
import javax.net.ssl.SSLSessionContext;
36-
import javax.security.cert.X509Certificate;
3736

3837
import io.undertow.UndertowMessages;
3938

@@ -257,10 +256,6 @@ public Certificate[] getLocalCertificates() {
257256
return null;
258257
}
259258

260-
public X509Certificate[] getPeerCertificateChain() throws SSLPeerUnverifiedException {
261-
throw new UnsupportedOperationException();
262-
}
263-
264259
public Principal getPeerPrincipal() throws SSLPeerUnverifiedException {
265260
throw new UnsupportedOperationException();
266261
}

core/src/main/java/io/undertow/server/BasicSSLSessionInfo.java

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424

2525
import javax.net.ssl.SSLPeerUnverifiedException;
2626
import javax.net.ssl.SSLSession;
27-
import javax.security.cert.CertificateException;
28-
import javax.security.cert.X509Certificate;
2927
import java.io.ByteArrayInputStream;
3028
import java.io.IOException;
3129
import java.nio.charset.StandardCharsets;
@@ -41,7 +39,6 @@ public class BasicSSLSessionInfo implements SSLSessionInfo {
4139
private final byte[] sessionId;
4240
private final String cypherSuite;
4341
private final java.security.cert.Certificate[] peerCertificate;
44-
private final X509Certificate[] certificate;
4542
private final Integer keySize;
4643

4744
/**
@@ -51,9 +48,8 @@ public class BasicSSLSessionInfo implements SSLSessionInfo {
5148
* @param certificate A string representation of the client certificate
5249
* @param keySize The key-size used by the cypher
5350
* @throws java.security.cert.CertificateException If the client cert could not be decoded
54-
* @throws CertificateException If the client cert could not be decoded
5551
*/
56-
public BasicSSLSessionInfo(byte[] sessionId, String cypherSuite, String certificate, Integer keySize) throws java.security.cert.CertificateException, CertificateException {
52+
public BasicSSLSessionInfo(byte[] sessionId, String cypherSuite, String certificate, Integer keySize) throws java.security.cert.CertificateException {
5753
this.sessionId = sessionId;
5854
this.cypherSuite = cypherSuite;
5955
this.keySize = keySize;
@@ -63,26 +59,13 @@ public BasicSSLSessionInfo(byte[] sessionId, String cypherSuite, String certific
6359
ByteArrayInputStream stream = new ByteArrayInputStream(certificateBytes);
6460
Collection<? extends java.security.cert.Certificate> certCol = cf.generateCertificates(stream);
6561
this.peerCertificate = new java.security.cert.Certificate[certCol.size()];
66-
X509Certificate[] legacyCertificate = new X509Certificate[certCol.size()];
6762
int i=0;
6863
for(java.security.cert.Certificate cert : certCol) {
6964
this.peerCertificate[i] = cert;
70-
if (legacyCertificate != null) {
71-
try {
72-
legacyCertificate[i] = X509Certificate.getInstance(cert.getEncoded());
73-
} catch (CertificateException ce) {
74-
// [UNDERTOW-1969] We don't care about deprecated JDK methods failure caused by the fact newer JDKs
75-
// doesn't support them anymore. "this.certificate" is used only by deprecated method
76-
// {@link SSLSessionInfo.getPeerCertificateChain()} which call should be avoided by API users.
77-
legacyCertificate = null;
78-
}
79-
}
8065
i++;
8166
}
82-
this.certificate = legacyCertificate;
8367
} else {
8468
this.peerCertificate = null;
85-
this.certificate = null;
8669
}
8770
}
8871

@@ -92,9 +75,8 @@ public BasicSSLSessionInfo(byte[] sessionId, String cypherSuite, String certific
9275
* @param cypherSuite The cypher suite name
9376
* @param certificate A string representation of the client certificate
9477
* @throws java.security.cert.CertificateException If the client cert could not be decoded
95-
* @throws CertificateException If the client cert could not be decoded
9678
*/
97-
public BasicSSLSessionInfo(byte[] sessionId, String cypherSuite, String certificate) throws java.security.cert.CertificateException, CertificateException {
79+
public BasicSSLSessionInfo(byte[] sessionId, String cypherSuite, String certificate) throws java.security.cert.CertificateException {
9880
this(sessionId, cypherSuite, certificate, null);
9981
}
10082

@@ -104,9 +86,8 @@ public BasicSSLSessionInfo(byte[] sessionId, String cypherSuite, String certific
10486
* @param cypherSuite The cypher suite name
10587
* @param certificate A string representation of the client certificate
10688
* @throws java.security.cert.CertificateException If the client cert could not be decoded
107-
* @throws CertificateException If the client cert could not be decoded
10889
*/
109-
public BasicSSLSessionInfo(String sessionId, String cypherSuite, String certificate) throws java.security.cert.CertificateException, CertificateException {
90+
public BasicSSLSessionInfo(String sessionId, String cypherSuite, String certificate) throws java.security.cert.CertificateException {
11091
this(sessionId == null ? null : fromHex(sessionId), cypherSuite, certificate, null);
11192
}
11293

@@ -117,9 +98,8 @@ public BasicSSLSessionInfo(String sessionId, String cypherSuite, String certific
11798
* @param certificate A string representation of the client certificate
11899
* @param keySize The key-size used by the cypher
119100
* @throws java.security.cert.CertificateException If the client cert could not be decoded
120-
* @throws CertificateException If the client cert could not be decoded
121101
*/
122-
public BasicSSLSessionInfo(String sessionId, String cypherSuite, String certificate, Integer keySize) throws java.security.cert.CertificateException, CertificateException {
102+
public BasicSSLSessionInfo(String sessionId, String cypherSuite, String certificate, Integer keySize) throws java.security.cert.CertificateException {
123103
this(sessionId == null ? null : fromHex(sessionId), cypherSuite, certificate, keySize);
124104
}
125105

@@ -155,15 +135,6 @@ public java.security.cert.Certificate[] getPeerCertificates() throws SSLPeerUnve
155135
return peerCertificate;
156136
}
157137

158-
@Deprecated
159-
@Override
160-
public X509Certificate[] getPeerCertificateChain() throws SSLPeerUnverifiedException {
161-
if (certificate == null) {
162-
throw UndertowMessages.MESSAGES.peerUnverified();
163-
}
164-
return certificate;
165-
}
166-
167138
@Override
168139
public void renegotiate(HttpServerExchange exchange, SslClientAuthMode sslClientAuthMode) throws IOException {
169140
throw UndertowMessages.MESSAGES.renegotiationNotSupported();

core/src/main/java/io/undertow/server/ConnectionSSLSessionInfo.java

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
import javax.net.ssl.SSLPeerUnverifiedException;
2727
import javax.net.ssl.SSLSession;
28-
import javax.security.cert.X509Certificate;
2928

3029
import org.xnio.ChannelListener;
3130
import org.xnio.IoUtils;
@@ -98,32 +97,6 @@ public Certificate[] getPeerCertificates() throws SSLPeerUnverifiedException, Re
9897
}
9998
}
10099

101-
@Override
102-
@Deprecated(since="2.2.3", forRemoval=false)
103-
public X509Certificate[] getPeerCertificateChain() throws SSLPeerUnverifiedException, RenegotiationRequiredException {
104-
if (unverified != null) {
105-
throw unverified;
106-
}
107-
if (renegotiationRequiredException != null) {
108-
throw renegotiationRequiredException;
109-
}
110-
try {
111-
return channel.getSslSession().getPeerCertificateChain();
112-
} catch (SSLPeerUnverifiedException e) {
113-
try {
114-
SslClientAuthMode sslClientAuthMode = channel.getOption(Options.SSL_CLIENT_AUTH_MODE);
115-
if (sslClientAuthMode == SslClientAuthMode.NOT_REQUESTED) {
116-
renegotiationRequiredException = RENEGOTIATION_REQUIRED_EXCEPTION;
117-
throw renegotiationRequiredException;
118-
}
119-
} catch (IOException ioe) {
120-
// ignore, will not actually happen
121-
}
122-
unverified = PEER_UNVERIFIED_EXCEPTION;
123-
throw unverified;
124-
}
125-
}
126-
127100
@Override
128101
public void renegotiate(HttpServerExchange exchange, SslClientAuthMode sslClientAuthMode) throws IOException {
129102
if ("TLSv1.3".equals(channel.getSslSession().getProtocol())) {

core/src/main/java/io/undertow/server/SSLSessionInfo.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,6 @@ default int getKeySize() {
100100
*/
101101
java.security.cert.Certificate[] getPeerCertificates() throws javax.net.ssl.SSLPeerUnverifiedException, RenegotiationRequiredException;
102102

103-
/**
104-
* This method is no longer supported on java 15 and should be avoided.
105-
* @deprecated in favor of {@link #getPeerCertificates()} because {@link SSLSession#getPeerCertificateChain()}
106-
* throws java 15.
107-
* @see SSLSession#getPeerCertificateChain()
108-
*/
109-
@Deprecated(since="2.2.3", forRemoval=false)
110-
javax.security.cert.X509Certificate[] getPeerCertificateChain() throws javax.net.ssl.SSLPeerUnverifiedException, RenegotiationRequiredException;
111-
112103
/**
113104
* Renegotiate in a blocking manner. This will set the client aut
114105
*

core/src/main/java/io/undertow/server/protocol/ajp/AjpRequestParseState.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,6 @@ BasicSSLSessionInfo createSslSessionInfo() {
128128
return new BasicSSLSessionInfo(sessionId, cypher, cert, keySize);
129129
} catch (CertificateException e) {
130130
return null;
131-
} catch (javax.security.cert.CertificateException e) {
132-
return null;
133131
}
134132
}
135133

core/src/main/java/io/undertow/server/protocol/http2/Http2SslSessionInfo.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.security.cert.Certificate;
2323
import javax.net.ssl.SSLPeerUnverifiedException;
2424
import javax.net.ssl.SSLSession;
25-
import javax.security.cert.X509Certificate;
2625
import org.xnio.Options;
2726
import org.xnio.SslClientAuthMode;
2827

@@ -70,24 +69,6 @@ public Certificate[] getPeerCertificates() throws SSLPeerUnverifiedException, Re
7069
}
7170
}
7271

73-
@Override
74-
public X509Certificate[] getPeerCertificateChain()
75-
throws SSLPeerUnverifiedException, RenegotiationRequiredException {
76-
try {
77-
return channel.getSslSession().getPeerCertificateChain();
78-
} catch (SSLPeerUnverifiedException e) {
79-
try {
80-
SslClientAuthMode sslClientAuthMode = channel.getOption(Options.SSL_CLIENT_AUTH_MODE);
81-
if (sslClientAuthMode == SslClientAuthMode.NOT_REQUESTED) {
82-
throw new RenegotiationRequiredException();
83-
}
84-
} catch (IOException e1) {
85-
// ignore, will not actually happen
86-
}
87-
throw e;
88-
}
89-
}
90-
9172
@Override
9273
public void renegotiate(HttpServerExchange exchange, SslClientAuthMode sslClientAuthMode) throws IOException {
9374
throw UndertowMessages.MESSAGES.renegotiationNotSupported();

core/src/main/java/io/undertow/util/Certificates.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@ public class Certificates {
2828

2929
public static final String END_CERT = "-----END CERTIFICATE-----";
3030

31-
@Deprecated (since = "2.3.0", forRemoval=true)
32-
public static String toPem(final javax.security.cert.X509Certificate certificate)
33-
throws javax.security.cert.CertificateEncodingException {
34-
return toPem(certificate.getEncoded());
35-
}
36-
3731
/**
3832
* Converts a certificate to PEM format.
3933
* @param certificate the Certificate to recode

0 commit comments

Comments
 (0)