Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip TLS SAN checks with self-signed trust strategy #695

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ && index < getInstructions().size()
if (getRequest().getMsgType() == MsgType.TO0_HELLO) {
logger.info("Failed TO0 with error: " + e.getMessage());
}

throw new IOException(e);
}

Expand Down Expand Up @@ -281,6 +281,7 @@ public void run() {

}
} catch (IOException e) {
logger.info(e);
throw new RuntimeException("Unable to establish connection with FDO Server");
} catch (Throwable throwable) {
if (getResponse() != null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
import org.apache.http.impl.client.CloseableHttpClient;
Expand All @@ -19,13 +21,18 @@ public class SelfSignedHttpClientSupplier implements HttpClientSupplier {
private static final SSLConnectionSocketFactory socketFactory = buildFactory();

static SSLConnectionSocketFactory buildFactory() {
HostnameVerifier hostnameVerifier = new HostnameVerifier() {
@Override
public boolean verify(String hostname, SSLSession session) {
return true;
}
};

try {
logger.warn("Using SSL self-signed certificate trust strategy for Http Clients");
SSLContextBuilder builder = new SSLContextBuilder();
builder.loadTrustMaterial(null, new TrustSelfSignedStrategy());
return new SSLConnectionSocketFactory(
builder.build());
return new SSLConnectionSocketFactory(builder.build(), hostnameVerifier);
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
} catch (KeyStoreException | KeyManagementException e) {
Expand Down
Loading