Skip to content

Commit

Permalink
Complete todo in SelfSignedCertificate (netty#9720)
Browse files Browse the repository at this point in the history
Motivation:

Easier to debug SelfSignedCertificate failures.

Modifications:

Add first throwable as suppressed to thrown exception.

Result:

Less technical debt.
  • Loading branch information
johnou authored and normanmaurer committed Oct 28, 2019
1 parent 816350f commit de537b9
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.netty.handler.codec.base64.Base64;
import io.netty.util.CharsetUtil;
import io.netty.util.internal.SystemPropertyUtil;
import io.netty.util.internal.ThrowableUtil;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;

Expand Down Expand Up @@ -162,10 +163,11 @@ public SelfSignedCertificate(String fqdn, SecureRandom random, int bits, Date no
paths = BouncyCastleSelfSignedCertGenerator.generate(fqdn, keypair, random, notBefore, notAfter);
} catch (Throwable t2) {
logger.debug("Failed to generate a self-signed X.509 certificate using Bouncy Castle:", t2);
throw new CertificateException(
final CertificateException certificateException = new CertificateException(
"No provider succeeded to generate a self-signed certificate. " +
"See debug log for the root cause.", t2);
// TODO: consider using Java 7 addSuppressed to append t
ThrowableUtil.addSuppressed(certificateException, t);
throw certificateException;
}
}

Expand Down

0 comments on commit de537b9

Please sign in to comment.