8282723: Add constructors taking a cause to JSSE exceptions
Reviewed-by: wetmore, iris
This commit is contained in:
parent
3f923b82c3
commit
4df67426ed
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -36,9 +36,7 @@ import java.io.IOException;
|
|||||||
* @since 1.4
|
* @since 1.4
|
||||||
* @author David Brownell
|
* @author David Brownell
|
||||||
*/
|
*/
|
||||||
public
|
public class SSLException extends IOException {
|
||||||
class SSLException extends IOException
|
|
||||||
{
|
|
||||||
@java.io.Serial
|
@java.io.Serial
|
||||||
private static final long serialVersionUID = 4511006460650708967L;
|
private static final long serialVersionUID = 4511006460650708967L;
|
||||||
|
|
||||||
@ -48,8 +46,7 @@ class SSLException extends IOException
|
|||||||
*
|
*
|
||||||
* @param reason describes the problem.
|
* @param reason describes the problem.
|
||||||
*/
|
*/
|
||||||
public SSLException(String reason)
|
public SSLException(String reason) {
|
||||||
{
|
|
||||||
super(reason);
|
super(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,8 +63,7 @@ class SSLException extends IOException
|
|||||||
* @since 1.5
|
* @since 1.5
|
||||||
*/
|
*/
|
||||||
public SSLException(String message, Throwable cause) {
|
public SSLException(String message, Throwable cause) {
|
||||||
super(message);
|
super(message, cause);
|
||||||
initCause(cause);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -83,7 +79,6 @@ class SSLException extends IOException
|
|||||||
* @since 1.5
|
* @since 1.5
|
||||||
*/
|
*/
|
||||||
public SSLException(Throwable cause) {
|
public SSLException(Throwable cause) {
|
||||||
super(cause == null ? null : cause.toString());
|
super(cause);
|
||||||
initCause(cause);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -23,10 +23,8 @@
|
|||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package javax.net.ssl;
|
package javax.net.ssl;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates that the client and server could not negotiate the
|
* Indicates that the client and server could not negotiate the
|
||||||
* desired level of security. The connection is no longer usable.
|
* desired level of security. The connection is no longer usable.
|
||||||
@ -34,9 +32,7 @@ package javax.net.ssl;
|
|||||||
* @since 1.4
|
* @since 1.4
|
||||||
* @author David Brownell
|
* @author David Brownell
|
||||||
*/
|
*/
|
||||||
public
|
public class SSLHandshakeException extends SSLException {
|
||||||
class SSLHandshakeException extends SSLException
|
|
||||||
{
|
|
||||||
@java.io.Serial
|
@java.io.Serial
|
||||||
private static final long serialVersionUID = -5045881315018326890L;
|
private static final long serialVersionUID = -5045881315018326890L;
|
||||||
|
|
||||||
@ -46,8 +42,23 @@ class SSLHandshakeException extends SSLException
|
|||||||
*
|
*
|
||||||
* @param reason describes the problem.
|
* @param reason describes the problem.
|
||||||
*/
|
*/
|
||||||
public SSLHandshakeException(String reason)
|
public SSLHandshakeException(String reason) {
|
||||||
{
|
|
||||||
super(reason);
|
super(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a {@code SSLHandshakeException} with the specified detail
|
||||||
|
* message and cause.
|
||||||
|
*
|
||||||
|
* @param message the detail message (which is saved for later retrieval
|
||||||
|
* by the {@link #getMessage()} method).
|
||||||
|
* @param cause the cause (which is saved for later retrieval by the
|
||||||
|
* {@link #getCause()} method). (A {@code null} value is
|
||||||
|
* permitted, and indicates that the cause is nonexistent or
|
||||||
|
* unknown.)
|
||||||
|
* @since 19
|
||||||
|
*/
|
||||||
|
public SSLHandshakeException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -33,9 +33,7 @@ package javax.net.ssl;
|
|||||||
* @since 1.4
|
* @since 1.4
|
||||||
* @author David Brownell
|
* @author David Brownell
|
||||||
*/
|
*/
|
||||||
public
|
public class SSLKeyException extends SSLException {
|
||||||
class SSLKeyException extends SSLException
|
|
||||||
{
|
|
||||||
@java.io.Serial
|
@java.io.Serial
|
||||||
private static final long serialVersionUID = -8071664081941937874L;
|
private static final long serialVersionUID = -8071664081941937874L;
|
||||||
|
|
||||||
@ -45,8 +43,23 @@ class SSLKeyException extends SSLException
|
|||||||
*
|
*
|
||||||
* @param reason describes the problem.
|
* @param reason describes the problem.
|
||||||
*/
|
*/
|
||||||
public SSLKeyException(String reason)
|
public SSLKeyException(String reason) {
|
||||||
{
|
|
||||||
super(reason);
|
super(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a {@code SSLKeyException} with the specified detail
|
||||||
|
* message and cause.
|
||||||
|
*
|
||||||
|
* @param message the detail message (which is saved for later retrieval
|
||||||
|
* by the {@link #getMessage()} method).
|
||||||
|
* @param cause the cause (which is saved for later retrieval by the
|
||||||
|
* {@link #getCause()} method). (A {@code null} value is
|
||||||
|
* permitted, and indicates that the cause is nonexistent or
|
||||||
|
* unknown.)
|
||||||
|
* @since 19
|
||||||
|
*/
|
||||||
|
public SSLKeyException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -39,9 +39,7 @@ package javax.net.ssl;
|
|||||||
* @since 1.4
|
* @since 1.4
|
||||||
* @author David Brownell
|
* @author David Brownell
|
||||||
*/
|
*/
|
||||||
public
|
public class SSLPeerUnverifiedException extends SSLException {
|
||||||
class SSLPeerUnverifiedException extends SSLException
|
|
||||||
{
|
|
||||||
@java.io.Serial
|
@java.io.Serial
|
||||||
private static final long serialVersionUID = -8919512675000600547L;
|
private static final long serialVersionUID = -8919512675000600547L;
|
||||||
|
|
||||||
@ -51,8 +49,23 @@ class SSLPeerUnverifiedException extends SSLException
|
|||||||
*
|
*
|
||||||
* @param reason describes the problem.
|
* @param reason describes the problem.
|
||||||
*/
|
*/
|
||||||
public SSLPeerUnverifiedException(String reason)
|
public SSLPeerUnverifiedException(String reason) {
|
||||||
{
|
|
||||||
super(reason);
|
super(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a {@code SSLPeerUnverifiedException} with the specified detail
|
||||||
|
* message and cause.
|
||||||
|
*
|
||||||
|
* @param message the detail message (which is saved for later retrieval
|
||||||
|
* by the {@link #getMessage()} method).
|
||||||
|
* @param cause the cause (which is saved for later retrieval by the
|
||||||
|
* {@link #getCause()} method). (A {@code null} value is
|
||||||
|
* permitted, and indicates that the cause is nonexistent or
|
||||||
|
* unknown.)
|
||||||
|
* @since 19
|
||||||
|
*/
|
||||||
|
public SSLPeerUnverifiedException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -33,9 +33,7 @@ package javax.net.ssl;
|
|||||||
* @since 1.4
|
* @since 1.4
|
||||||
* @author David Brownell
|
* @author David Brownell
|
||||||
*/
|
*/
|
||||||
public
|
public class SSLProtocolException extends SSLException {
|
||||||
class SSLProtocolException extends SSLException
|
|
||||||
{
|
|
||||||
@java.io.Serial
|
@java.io.Serial
|
||||||
private static final long serialVersionUID = 5445067063799134928L;
|
private static final long serialVersionUID = 5445067063799134928L;
|
||||||
|
|
||||||
@ -45,8 +43,23 @@ class SSLProtocolException extends SSLException
|
|||||||
*
|
*
|
||||||
* @param reason describes the problem.
|
* @param reason describes the problem.
|
||||||
*/
|
*/
|
||||||
public SSLProtocolException(String reason)
|
public SSLProtocolException(String reason) {
|
||||||
{
|
|
||||||
super(reason);
|
super(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a {@code SSLProtocolException} with the specified detail
|
||||||
|
* message and cause.
|
||||||
|
*
|
||||||
|
* @param message the detail message (which is saved for later retrieval
|
||||||
|
* by the {@link #getMessage()} method).
|
||||||
|
* @param cause the cause (which is saved for later retrieval by the
|
||||||
|
* {@link #getCause()} method). (A {@code null} value is
|
||||||
|
* permitted, and indicates that the cause is nonexistent or
|
||||||
|
* unknown.)
|
||||||
|
* @since 19
|
||||||
|
*/
|
||||||
|
public SSLProtocolException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -122,22 +122,15 @@ enum Alert {
|
|||||||
reason = (cause != null) ? cause.getMessage() : "";
|
reason = (cause != null) ? cause.getMessage() : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
SSLException ssle;
|
|
||||||
if (cause instanceof IOException) {
|
if (cause instanceof IOException) {
|
||||||
ssle = new SSLException(reason);
|
return new SSLException(reason, cause);
|
||||||
} else if ((this == UNEXPECTED_MESSAGE)) {
|
} else if ((this == UNEXPECTED_MESSAGE)) {
|
||||||
ssle = new SSLProtocolException(reason);
|
return new SSLProtocolException(reason, cause);
|
||||||
} else if (handshakeOnly) {
|
} else if (handshakeOnly) {
|
||||||
ssle = new SSLHandshakeException(reason);
|
return new SSLHandshakeException(reason, cause);
|
||||||
} else {
|
} else {
|
||||||
ssle = new SSLException(reason);
|
return new SSLException(reason, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cause != null) {
|
|
||||||
ssle.initCause(cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ssle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -295,8 +295,8 @@ final class DHClientKeyExchange {
|
|||||||
shc.handshakeCredentials.add(
|
shc.handshakeCredentials.add(
|
||||||
new DHECredentials(peerPublicKey, namedGroup));
|
new DHECredentials(peerPublicKey, namedGroup));
|
||||||
} catch (GeneralSecurityException | java.io.IOException e) {
|
} catch (GeneralSecurityException | java.io.IOException e) {
|
||||||
throw (SSLHandshakeException)(new SSLHandshakeException(
|
throw new SSLHandshakeException(
|
||||||
"Could not generate DHPublicKey").initCause(e));
|
"Could not generate DHPublicKey", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the states
|
// update the states
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -160,8 +160,7 @@ final class ECDHKeyExchange {
|
|||||||
ka.doPhase(peerPublicKey, true);
|
ka.doPhase(peerPublicKey, true);
|
||||||
return ka.generateSecret("TlsPremasterSecret");
|
return ka.generateSecret("TlsPremasterSecret");
|
||||||
} catch (GeneralSecurityException e) {
|
} catch (GeneralSecurityException e) {
|
||||||
throw (SSLHandshakeException) new SSLHandshakeException(
|
throw new SSLHandshakeException("Could not generate secret", e);
|
||||||
"Could not generate secret").initCause(e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,8 +176,7 @@ final class ECDHKeyExchange {
|
|||||||
PublicKey peerPublicKey = kf.generatePublic(spec);
|
PublicKey peerPublicKey = kf.generatePublic(spec);
|
||||||
return getAgreedSecret(peerPublicKey);
|
return getAgreedSecret(peerPublicKey);
|
||||||
} catch (GeneralSecurityException | java.io.IOException e) {
|
} catch (GeneralSecurityException | java.io.IOException e) {
|
||||||
throw (SSLHandshakeException) new SSLHandshakeException(
|
throw new SSLHandshakeException("Could not generate secret", e);
|
||||||
"Could not generate secret").initCause(e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,8 +200,8 @@ final class ECDHKeyExchange {
|
|||||||
"ECPublicKey does not comply to algorithm constraints");
|
"ECPublicKey does not comply to algorithm constraints");
|
||||||
}
|
}
|
||||||
} catch (GeneralSecurityException | java.io.IOException e) {
|
} catch (GeneralSecurityException | java.io.IOException e) {
|
||||||
throw (SSLHandshakeException) new SSLHandshakeException(
|
throw new SSLHandshakeException(
|
||||||
"Could not generate ECPublicKey").initCause(e);
|
"Could not generate ECPublicKey", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -88,8 +88,7 @@ public class KAKeyDerivation implements SSLKeyDerivation {
|
|||||||
context, preMasterSecret);
|
context, preMasterSecret);
|
||||||
return kd.deriveKey("MasterSecret", params);
|
return kd.deriveKey("MasterSecret", params);
|
||||||
} catch (GeneralSecurityException gse) {
|
} catch (GeneralSecurityException gse) {
|
||||||
throw (SSLHandshakeException) new SSLHandshakeException(
|
throw new SSLHandshakeException("Could not generate secret", gse);
|
||||||
"Could not generate secret").initCause(gse);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,8 +124,7 @@ public class KAKeyDerivation implements SSLKeyDerivation {
|
|||||||
// derive handshake secret
|
// derive handshake secret
|
||||||
return hkdf.extract(saltSecret, sharedSecret, algorithm);
|
return hkdf.extract(saltSecret, sharedSecret, algorithm);
|
||||||
} catch (GeneralSecurityException gse) {
|
} catch (GeneralSecurityException gse) {
|
||||||
throw (SSLHandshakeException) new SSLHandshakeException(
|
throw new SSLHandshakeException("Could not generate secret", gse);
|
||||||
"Could not generate secret").initCause(gse);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -302,8 +302,7 @@ final class NewSessionTicket {
|
|||||||
return hkdf.expand(resumptionMasterSecret, hkdfInfo,
|
return hkdf.expand(resumptionMasterSecret, hkdfInfo,
|
||||||
hashAlg.hashLength, "TlsPreSharedKey");
|
hashAlg.hashLength, "TlsPreSharedKey");
|
||||||
} catch (GeneralSecurityException gse) {
|
} catch (GeneralSecurityException gse) {
|
||||||
throw (SSLHandshakeException) new SSLHandshakeException(
|
throw new SSLHandshakeException("Could not derive PSK", gse);
|
||||||
"Could not derive PSK").initCause(gse);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -52,8 +52,7 @@ final class SSLBasicKeyDerivation implements SSLKeyDerivation {
|
|||||||
return hkdf.expand(secret, hkdfInfo,
|
return hkdf.expand(secret, hkdfInfo,
|
||||||
((SecretSizeSpec)keySpec).length, algorithm);
|
((SecretSizeSpec)keySpec).length, algorithm);
|
||||||
} catch (GeneralSecurityException gse) {
|
} catch (GeneralSecurityException gse) {
|
||||||
throw (SSLHandshakeException) new SSLHandshakeException(
|
throw new SSLHandshakeException("Could not generate secret", gse);
|
||||||
"Could not generate secret").initCause(gse);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -1167,17 +1167,13 @@ final class SSLEngineImpl extends SSLEngine implements SSLTransport {
|
|||||||
if (taskThrown instanceof RuntimeException) {
|
if (taskThrown instanceof RuntimeException) {
|
||||||
throw new RuntimeException(msg, taskThrown);
|
throw new RuntimeException(msg, taskThrown);
|
||||||
} else if (taskThrown instanceof SSLHandshakeException) {
|
} else if (taskThrown instanceof SSLHandshakeException) {
|
||||||
return (SSLHandshakeException)
|
return new SSLHandshakeException(msg, taskThrown);
|
||||||
new SSLHandshakeException(msg).initCause(taskThrown);
|
|
||||||
} else if (taskThrown instanceof SSLKeyException) {
|
} else if (taskThrown instanceof SSLKeyException) {
|
||||||
return (SSLKeyException)
|
return new SSLKeyException(msg, taskThrown);
|
||||||
new SSLKeyException(msg).initCause(taskThrown);
|
|
||||||
} else if (taskThrown instanceof SSLPeerUnverifiedException) {
|
} else if (taskThrown instanceof SSLPeerUnverifiedException) {
|
||||||
return (SSLPeerUnverifiedException)
|
return new SSLPeerUnverifiedException(msg, taskThrown);
|
||||||
new SSLPeerUnverifiedException(msg).initCause(taskThrown);
|
|
||||||
} else if (taskThrown instanceof SSLProtocolException) {
|
} else if (taskThrown instanceof SSLProtocolException) {
|
||||||
return (SSLProtocolException)
|
return new SSLProtocolException(msg, taskThrown);
|
||||||
new SSLProtocolException(msg).initCause(taskThrown);
|
|
||||||
} else if (taskThrown instanceof SSLException) {
|
} else if (taskThrown instanceof SSLException) {
|
||||||
return (SSLException)taskThrown;
|
return (SSLException)taskThrown;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -242,8 +242,7 @@ final class SSLEngineInputRecord extends InputRecord implements SSLRecord {
|
|||||||
} catch (BadPaddingException bpe) {
|
} catch (BadPaddingException bpe) {
|
||||||
throw bpe;
|
throw bpe;
|
||||||
} catch (GeneralSecurityException gse) {
|
} catch (GeneralSecurityException gse) {
|
||||||
throw (SSLProtocolException)(new SSLProtocolException(
|
throw new SSLProtocolException("Unexpected exception", gse);
|
||||||
"Unexpected exception")).initCause(gse);
|
|
||||||
} finally {
|
} finally {
|
||||||
// consume a complete record
|
// consume a complete record
|
||||||
packet.limit(srcLim);
|
packet.limit(srcLim);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -113,8 +113,7 @@ final class SSLSecretDerivation implements SSLKeyDerivation {
|
|||||||
HKDF hkdf = new HKDF(hashAlg.name);
|
HKDF hkdf = new HKDF(hashAlg.name);
|
||||||
return hkdf.expand(secret, hkdfInfo, hashAlg.hashLength, algorithm);
|
return hkdf.expand(secret, hkdfInfo, hashAlg.hashLength, algorithm);
|
||||||
} catch (GeneralSecurityException gse) {
|
} catch (GeneralSecurityException gse) {
|
||||||
throw (SSLHandshakeException) new SSLHandshakeException(
|
throw new SSLHandshakeException("Could not generate secret", gse);
|
||||||
"Could not generate secret").initCause(gse);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -1709,19 +1709,13 @@ public final class SSLSocketImpl
|
|||||||
|
|
||||||
private Plaintext handleEOF(EOFException eofe) throws IOException {
|
private Plaintext handleEOF(EOFException eofe) throws IOException {
|
||||||
if (requireCloseNotify || conContext.handshakeContext != null) {
|
if (requireCloseNotify || conContext.handshakeContext != null) {
|
||||||
SSLException ssle;
|
|
||||||
if (conContext.handshakeContext != null) {
|
if (conContext.handshakeContext != null) {
|
||||||
ssle = new SSLHandshakeException(
|
throw new SSLHandshakeException(
|
||||||
"Remote host terminated the handshake");
|
"Remote host terminated the handshake", eofe);
|
||||||
} else {
|
} else {
|
||||||
ssle = new SSLProtocolException(
|
throw new SSLProtocolException(
|
||||||
"Remote host terminated the connection");
|
"Remote host terminated the connection", eofe);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eofe != null) {
|
|
||||||
ssle.initCause(eofe);
|
|
||||||
}
|
|
||||||
throw ssle;
|
|
||||||
} else {
|
} else {
|
||||||
// treat as if we had received a close_notify
|
// treat as if we had received a close_notify
|
||||||
conContext.isInputCloseNotified = true;
|
conContext.isInputCloseNotified = true;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* Copyright (c) 2020, Azul Systems, Inc. All rights reserved.
|
* Copyright (c) 2020, Azul Systems, Inc. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
@ -263,8 +263,7 @@ final class SSLSocketInputRecord extends InputRecord implements SSLRecord {
|
|||||||
} catch (BadPaddingException bpe) {
|
} catch (BadPaddingException bpe) {
|
||||||
throw bpe;
|
throw bpe;
|
||||||
} catch (GeneralSecurityException gse) {
|
} catch (GeneralSecurityException gse) {
|
||||||
throw (SSLProtocolException)(new SSLProtocolException(
|
throw new SSLProtocolException("Unexpected exception", gse);
|
||||||
"Unexpected exception")).initCause(gse);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contentType != ContentType.HANDSHAKE.id &&
|
if (contentType != ContentType.HANDSHAKE.id &&
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -154,8 +154,8 @@ enum SSLTrafficKeyDerivation implements SSLKeyDerivationGenerator {
|
|||||||
ks.getKeyLength(cs),
|
ks.getKeyLength(cs),
|
||||||
ks.getAlgorithm(cs, algorithm));
|
ks.getAlgorithm(cs, algorithm));
|
||||||
} catch (GeneralSecurityException gse) {
|
} catch (GeneralSecurityException gse) {
|
||||||
throw (SSLHandshakeException)(new SSLHandshakeException(
|
throw new SSLHandshakeException(
|
||||||
"Could not generate secret").initCause(gse));
|
"Could not generate secret", gse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -1205,8 +1205,7 @@ final class ServerHello {
|
|||||||
hc.handshakeKeyDerivation =
|
hc.handshakeKeyDerivation =
|
||||||
new SSLSecretDerivation(hc, earlySecret);
|
new SSLSecretDerivation(hc, earlySecret);
|
||||||
} catch (GeneralSecurityException gse) {
|
} catch (GeneralSecurityException gse) {
|
||||||
throw (SSLHandshakeException) new SSLHandshakeException(
|
throw new SSLHandshakeException("Could not generate secret", gse);
|
||||||
"Could not generate secret").initCause(gse);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -135,9 +135,8 @@ final class ServerNameExtension {
|
|||||||
nameType + "), name=" +
|
nameType + "), name=" +
|
||||||
(new String(encoded, StandardCharsets.UTF_8)) +
|
(new String(encoded, StandardCharsets.UTF_8)) +
|
||||||
", value={" +
|
", value={" +
|
||||||
Utilities.toHexString(encoded) + "}");
|
Utilities.toHexString(encoded) + "}", iae);
|
||||||
throw hc.conContext.fatal(Alert.ILLEGAL_PARAMETER,
|
throw hc.conContext.fatal(Alert.ILLEGAL_PARAMETER, spe);
|
||||||
(SSLProtocolException)spe.initCause(iae));
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
@ -146,9 +145,8 @@ final class ServerNameExtension {
|
|||||||
SSLProtocolException spe = new SSLProtocolException(
|
SSLProtocolException spe = new SSLProtocolException(
|
||||||
"Illegal server name, type=(" + nameType +
|
"Illegal server name, type=(" + nameType +
|
||||||
"), value={" +
|
"), value={" +
|
||||||
Utilities.toHexString(encoded) + "}");
|
Utilities.toHexString(encoded) + "}", iae);
|
||||||
throw hc.conContext.fatal(Alert.ILLEGAL_PARAMETER,
|
throw hc.conContext.fatal(Alert.ILLEGAL_PARAMETER, spe);
|
||||||
(SSLProtocolException)spe.initCause(iae));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -435,11 +435,10 @@ public final class StartTlsResponseImpl extends StartTlsResponse {
|
|||||||
/*
|
/*
|
||||||
* Pass up the cause of the failure
|
* Pass up the cause of the failure
|
||||||
*/
|
*/
|
||||||
throw(SSLPeerUnverifiedException)
|
throw new SSLPeerUnverifiedException("hostname of the server '" +
|
||||||
new SSLPeerUnverifiedException("hostname of the server '" +
|
|
||||||
hostname +
|
hostname +
|
||||||
"' does not match the hostname in the " +
|
"' does not match the hostname in the " +
|
||||||
"server's certificate.").initCause(e);
|
"server's certificate.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -573,9 +573,7 @@ final class HttpClientImpl extends HttpClient implements Trackable {
|
|||||||
throw ce;
|
throw ce;
|
||||||
} else if (throwable instanceof SSLHandshakeException) {
|
} else if (throwable instanceof SSLHandshakeException) {
|
||||||
// special case for SSLHandshakeException
|
// special case for SSLHandshakeException
|
||||||
SSLHandshakeException he = new SSLHandshakeException(msg);
|
throw new SSLHandshakeException(msg, throwable);
|
||||||
he.initCause(throwable);
|
|
||||||
throw he;
|
|
||||||
} else if (throwable instanceof SSLException) {
|
} else if (throwable instanceof SSLException) {
|
||||||
// any other SSLException is wrapped in a plain
|
// any other SSLException is wrapped in a plain
|
||||||
// SSLException
|
// SSLException
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -592,9 +592,7 @@ public class SSLTube implements FlowTube {
|
|||||||
engine.isOutboundDone(),
|
engine.isOutboundDone(),
|
||||||
handshakeFailed);
|
handshakeFailed);
|
||||||
|
|
||||||
SSLHandshakeException e = new SSLHandshakeException(handshakeFailed);
|
return new SSLHandshakeException(handshakeFailed, t);
|
||||||
if (t != null) e.initCause(t);
|
|
||||||
return e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -484,7 +484,7 @@ public class SSLServerSocketAlpnTest {
|
|||||||
*/
|
*/
|
||||||
if ((local != null) && (remote != null)) {
|
if ((local != null) && (remote != null)) {
|
||||||
// If both failed, return the curthread's exception.
|
// If both failed, return the curthread's exception.
|
||||||
local.initCause(remote);
|
local.addSuppressed(remote);
|
||||||
exception = local;
|
exception = local;
|
||||||
} else if (local != null) {
|
} else if (local != null) {
|
||||||
exception = local;
|
exception = local;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -480,7 +480,7 @@ public class SSLSocketAlpnTest {
|
|||||||
*/
|
*/
|
||||||
if ((local != null) && (remote != null)) {
|
if ((local != null) && (remote != null)) {
|
||||||
// If both failed, return the curthread's exception.
|
// If both failed, return the curthread's exception.
|
||||||
local.initCause(remote);
|
local.addSuppressed(remote);
|
||||||
exception = local;
|
exception = local;
|
||||||
} else if (local != null) {
|
} else if (local != null) {
|
||||||
exception = local;
|
exception = local;
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @test
|
||||||
|
* @bug 8282723
|
||||||
|
* @summary Add constructors taking a cause to JSSE exceptions
|
||||||
|
*/
|
||||||
|
import javax.net.ssl.SSLHandshakeException;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class CheckSSLHandshakeException {
|
||||||
|
private static String exceptionMessage = "message";
|
||||||
|
private static Throwable exceptionCause = new RuntimeException();
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
testException(
|
||||||
|
new SSLHandshakeException(exceptionMessage, exceptionCause));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void testException(Exception ex) {
|
||||||
|
if (!Objects.equals(ex.getMessage(), exceptionMessage)) {
|
||||||
|
throw new RuntimeException("Unexpected exception message");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ex.getCause() != exceptionCause) {
|
||||||
|
throw new RuntimeException("Unexpected exception cause");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @test
|
||||||
|
* @bug 8282723
|
||||||
|
* @summary Add constructors taking a cause to JSSE exceptions
|
||||||
|
*/
|
||||||
|
import javax.net.ssl.SSLKeyException;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class CheckSSLKeyException {
|
||||||
|
private static String exceptionMessage = "message";
|
||||||
|
private static Throwable exceptionCause = new RuntimeException();
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
testException(
|
||||||
|
new SSLKeyException(exceptionMessage, exceptionCause));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void testException(Exception ex) {
|
||||||
|
if (!Objects.equals(ex.getMessage(), exceptionMessage)) {
|
||||||
|
throw new RuntimeException("Unexpected exception message");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ex.getCause() != exceptionCause) {
|
||||||
|
throw new RuntimeException("Unexpected exception cause");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @test
|
||||||
|
* @bug 8282723
|
||||||
|
* @summary Add constructors taking a cause to JSSE exceptions
|
||||||
|
*/
|
||||||
|
import javax.net.ssl.SSLPeerUnverifiedException;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class CheckSSLPeerUnverifiedException {
|
||||||
|
private static String exceptionMessage = "message";
|
||||||
|
private static Throwable exceptionCause = new RuntimeException();
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
testException(
|
||||||
|
new SSLPeerUnverifiedException(exceptionMessage, exceptionCause));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void testException(Exception ex) {
|
||||||
|
if (!Objects.equals(ex.getMessage(), exceptionMessage)) {
|
||||||
|
throw new RuntimeException("Unexpected exception message");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ex.getCause() != exceptionCause) {
|
||||||
|
throw new RuntimeException("Unexpected exception cause");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @test
|
||||||
|
* @bug 8282723
|
||||||
|
* @summary Add constructors taking a cause to JSSE exceptions
|
||||||
|
*/
|
||||||
|
import javax.net.ssl.SSLProtocolException;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class CheckSSLProtocolException {
|
||||||
|
private static String exceptionMessage = "message";
|
||||||
|
private static Throwable exceptionCause = new RuntimeException();
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
testException(
|
||||||
|
new SSLProtocolException(exceptionMessage, exceptionCause));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void testException(Exception ex) {
|
||||||
|
if (!Objects.equals(ex.getMessage(), exceptionMessage)) {
|
||||||
|
throw new RuntimeException("Unexpected exception message");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ex.getCause() != exceptionCause) {
|
||||||
|
throw new RuntimeException("Unexpected exception cause");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -349,13 +349,13 @@ public class SSLSocketSSLEngineTemplate {
|
|||||||
} finally {
|
} finally {
|
||||||
if (serverException != null) {
|
if (serverException != null) {
|
||||||
if (clientException != null) {
|
if (clientException != null) {
|
||||||
serverException.initCause(clientException);
|
serverException.addSuppressed(clientException);
|
||||||
}
|
}
|
||||||
throw serverException;
|
throw serverException;
|
||||||
}
|
}
|
||||||
if (clientException != null) {
|
if (clientException != null) {
|
||||||
if (serverException != null) {
|
if (serverException != null) {
|
||||||
clientException.initCause(serverException);
|
clientException.addSuppressed(serverException);
|
||||||
}
|
}
|
||||||
throw clientException;
|
throw clientException;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -544,7 +544,7 @@ public class SSLSocketTemplate {
|
|||||||
*/
|
*/
|
||||||
if ((local != null) && (remote != null)) {
|
if ((local != null) && (remote != null)) {
|
||||||
// If both failed, return the curthread's exception.
|
// If both failed, return the curthread's exception.
|
||||||
local.initCause(remote);
|
local.addSuppressed(remote);
|
||||||
exception = local;
|
exception = local;
|
||||||
} else if (local != null) {
|
} else if (local != null) {
|
||||||
exception = local;
|
exception = local;
|
||||||
|
Loading…
Reference in New Issue
Block a user