Skip to content

Commit

Permalink
Better log about server certificate validation at client side.
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernard31 committed Sep 15, 2020
1 parent df08289 commit 74d9ed3
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,18 @@ public void verifyCertificate(CertificateMessage message, DTLSSession session)
if (message.getCertificateChain().getCertificates().size() == 0) {
AlertMessage alert = new AlertMessage(AlertLevel.FATAL, AlertDescription.BAD_CERTIFICATE,
session.getPeer());
throw new HandshakeException("Certificate chain could not be validated", alert);
throw new HandshakeException(
"Certificate chain could not be validated : server cert chain is empty", alert);
}
Certificate receivedServerCertificate = message.getCertificateChain().getCertificates().get(0);

// Validate certificate
if (!expectedServerCertificate.equals(receivedServerCertificate)) {
AlertMessage alert = new AlertMessage(AlertLevel.FATAL, AlertDescription.BAD_CERTIFICATE,
session.getPeer());
throw new HandshakeException("Certificate chain could not be validated", alert);
throw new HandshakeException(
"Certificate chain could not be validated: server certificate does not match expected one ('domain-issue certificate' usage)",
alert);
}
}

Expand Down

0 comments on commit 74d9ed3

Please sign in to comment.