-
Notifications
You must be signed in to change notification settings - Fork 63
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
Configurable certificate validation #122
Changes from all commits
5261c6b
6a67513
909eea1
c54b558
6e8e213
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,8 @@ | |
|
||
@Slf4j | ||
public class TomcatServerFactory { | ||
private final static String SERVLET_NAME = "hello"; | ||
private static final String SERVLET_NAME = "hello"; | ||
private static final String STORE_PASSWORD = "password"; // NOSONAR | ||
|
||
public Tomcat startTomcat(HttpsConfig httpsConfig) throws IOException { | ||
Tomcat tomcat = new Tomcat(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ServletException is never thrown |
||
|
@@ -67,7 +68,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response) | |
try { | ||
tomcat.start(); | ||
} catch (LifecycleException e) { | ||
throw new RuntimeException(e); | ||
throw new RuntimeException(e); // NOSONAR | ||
} | ||
return tomcat; | ||
} | ||
|
@@ -77,9 +78,14 @@ private Connector createHttpsConnector(HttpsConfig httpsConfig) { | |
httpsConnector.setPort(0); | ||
httpsConnector.setSecure(true); | ||
httpsConnector.setScheme("https"); | ||
httpsConnector.setAttribute("clientAuth", | ||
Boolean.toString(httpsConfig.isClientAuth() && httpsConfig.isVerifySslCertificatesOfServices())); | ||
httpsConnector.setAttribute("keystoreFile", httpsConfig.getKeyStore()); | ||
httpsConnector.setAttribute("clientAuth", Boolean.toString(httpsConfig.isClientAuth())); | ||
httpsConnector.setAttribute("keystorePass", httpsConfig.getKeyPassword()); | ||
httpsConnector.setAttribute("keystorePass", httpsConfig.getKeyStorePassword()); | ||
if (httpsConfig.isClientAuth()) { | ||
httpsConnector.setAttribute("truststoreFile", httpsConfig.getTrustStore()); | ||
httpsConnector.setAttribute("truststorePass", httpsConfig.getTrustStorePassword()); | ||
} | ||
httpsConnector.setAttribute("sslProtocol", httpsConfig.getProtocol()); | ||
httpsConnector.setAttribute("SSLEnabled", true); | ||
return httpsConnector; | ||
|
@@ -103,9 +109,9 @@ public static void main(String[] args) throws LifecycleException, ClientProtocol | |
|
||
HttpsConfig httpsConfig = HttpsConfig.builder() | ||
.keyStore(new File("keystore/localhost/localhost.keystore.p12").getCanonicalPath()) | ||
.keyStorePassword("password").keyPassword("password") | ||
.keyStorePassword(STORE_PASSWORD).keyPassword(STORE_PASSWORD) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ClientProtocolException is never thrown because of more general exception |
||
.trustStore(new File("keystore/localhost/localhost.truststore.p12").getCanonicalPath()) | ||
.trustStorePassword("password").protocol("TLSv1.2").build(); | ||
.trustStorePassword(STORE_PASSWORD).protocol("TLSv1.2").build(); | ||
HttpsFactory httpsFactory = new HttpsFactory(httpsConfig); | ||
|
||
Tomcat tomcat = new TomcatServerFactory().startTomcat(httpsConfig); | ||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IOException is never thrown