use of ch.cyberduck.core.exception.SSLNegotiateException in project cyberduck by iterate-ch.
the class SSLExceptionMappingService method map.
/**
* close_notify(0),
* unexpected_message(10),
* bad_record_mac(20),
* decryption_failed_RESERVED(21),
* record_overflow(22),
* decompression_failure(30),
* handshake_failure(40),
* no_certificate_RESERVED(41),
* bad_certificate(42),
* unsupported_certificate(43),
* certificate_revoked(44),
* certificate_expired(45),
* certificate_unknown(46),
* illegal_parameter(47),
* unknown_ca(48),
* access_denied(49),
* decode_error(50),
* decrypt_error(51),
* export_restriction_RESERVED(60),
* protocol_version(70),
* insufficient_security(71),
* internal_error(80),
* user_canceled(90),
* no_renegotiation(100),
* unsupported_extension(110),
*/
@Override
public BackgroundException map(final SSLException failure) {
final StringBuilder buffer = new StringBuilder();
for (Throwable cause : ExceptionUtils.getThrowableList(failure)) {
if (cause instanceof SocketException) {
// Connection has been shutdown: javax.net.ssl.SSLException: java.net.SocketException: Broken pipe
return new DefaultSocketExceptionMappingService().map((SocketException) cause);
}
}
final String message = failure.getMessage();
for (Alert alert : Alert.values()) {
if (StringUtils.containsIgnoreCase(message, alert.name())) {
this.append(buffer, alert.getDescription());
break;
}
}
if (failure instanceof SSLHandshakeException) {
if (ExceptionUtils.getRootCause(failure) instanceof CertificateException) {
log.warn(String.format("Ignore certificate failure %s and drop connection", failure.getMessage()));
// Server certificate not accepted
return new ConnectionCanceledException(failure);
}
if (ExceptionUtils.getRootCause(failure) instanceof EOFException) {
// SSL peer shut down incorrectly
return this.wrap(failure, buffer);
}
return new SSLNegotiateException(buffer.toString(), failure);
}
if (ExceptionUtils.getRootCause(failure) instanceof GeneralSecurityException) {
this.append(buffer, ExceptionUtils.getRootCause(failure).getMessage());
return new InteroperabilityException(buffer.toString(), failure);
}
this.append(buffer, message);
return new InteroperabilityException(buffer.toString(), failure);
}
Aggregations