SMTP: Don't treat all TLS errors as certificate error

This commit is contained in:
cketti 2022-10-28 16:36:59 +02:00
parent 05d0038a67
commit 1570c2389f

View file

@ -34,6 +34,7 @@ import java.net.InetSocketAddress
import java.net.Socket import java.net.Socket
import java.net.UnknownHostException import java.net.UnknownHostException
import java.security.GeneralSecurityException import java.security.GeneralSecurityException
import java.security.cert.CertificateException
import java.util.Locale import java.util.Locale
import javax.net.ssl.SSLException import javax.net.ssl.SSLException
import org.apache.commons.io.IOUtils import org.apache.commons.io.IOUtils
@ -230,7 +231,11 @@ class SmtpTransport(
throw e throw e
} catch (e: SSLException) { } catch (e: SSLException) {
close() close()
throw CertificateValidationException(e.message, e) if (e.cause is CertificateException) {
throw CertificateValidationException(e.message, e)
} else {
throw e
}
} catch (e: GeneralSecurityException) { } catch (e: GeneralSecurityException) {
close() close()
throw MessagingException("Unable to open connection to SMTP server due to security error.", e) throw MessagingException("Unable to open connection to SMTP server due to security error.", e)