Merge branch 'stable-3.0' into stable-3.1
* stable-3.0: Verify hostname when sending emails via SMTP server with SMTPSClient Docs: Clarify that 'm' push option sets patch set description Change-Id: I1b69e72b1ad64c842bce2f174b52b073c9e5edac
This commit is contained in:
@@ -392,11 +392,7 @@ public class SmtpEmailSender implements EmailSender {
|
||||
}
|
||||
|
||||
private SMTPClient open() throws EmailException {
|
||||
final AuthSMTPClient client = new AuthSMTPClient(UTF_8.name());
|
||||
|
||||
if (smtpEncryption == Encryption.SSL) {
|
||||
client.enableSSL(sslVerify);
|
||||
}
|
||||
final AuthSMTPClient client = new AuthSMTPClient(smtpEncryption == Encryption.SSL, sslVerify);
|
||||
|
||||
client.setConnectTimeout(connectTimeout);
|
||||
try {
|
||||
@@ -412,7 +408,7 @@ public class SmtpEmailSender implements EmailSender {
|
||||
}
|
||||
|
||||
if (smtpEncryption == Encryption.TLS) {
|
||||
if (!client.startTLS(smtpHost, smtpPort, sslVerify)) {
|
||||
if (!client.execTLS()) {
|
||||
throw new EmailException("SMTP server does not support TLS");
|
||||
}
|
||||
if (!client.login()) {
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.net.Socket;
|
||||
import java.net.UnknownHostException;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.cert.X509Certificate;
|
||||
import javax.net.SocketFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
@@ -32,19 +31,7 @@ public class BlindSSLSocketFactory extends SSLSocketFactory {
|
||||
private static final BlindSSLSocketFactory INSTANCE;
|
||||
|
||||
static {
|
||||
final X509TrustManager dummyTrustManager =
|
||||
new X509TrustManager() {
|
||||
@Override
|
||||
public X509Certificate[] getAcceptedIssuers() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkClientTrusted(X509Certificate[] chain, String authType) {}
|
||||
|
||||
@Override
|
||||
public void checkServerTrusted(X509Certificate[] chain, String authType) {}
|
||||
};
|
||||
final X509TrustManager dummyTrustManager = new BlindTrustManager();
|
||||
|
||||
try {
|
||||
final SSLContext context = SSLContext.getInstance("SSL");
|
||||
|
||||
33
java/com/google/gerrit/util/ssl/BlindTrustManager.java
Normal file
33
java/com/google/gerrit/util/ssl/BlindTrustManager.java
Normal file
@@ -0,0 +1,33 @@
|
||||
// Copyright (C) 2020 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.util.ssl;
|
||||
|
||||
import java.security.cert.X509Certificate;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
|
||||
/** TrustManager implementation that accepts all certificates without validation. */
|
||||
public class BlindTrustManager implements X509TrustManager {
|
||||
|
||||
@Override
|
||||
public X509Certificate[] getAcceptedIssuers() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkClientTrusted(X509Certificate[] chain, String authType) {}
|
||||
|
||||
@Override
|
||||
public void checkServerTrusted(X509Certificate[] chain, String authType) {}
|
||||
}
|
||||
Reference in New Issue
Block a user