Using Embedded Tomcat 10 in SpringBoot, trying to manually configure a new
HTTPS/SSL port. I've got the following SSL bundle set in my application
properties (fairly sure this part is working fine):

spring.ssl.bundle.jks.rbupbundle.key.alias=RBup

spring.ssl.bundle.jks.rbupbundle.keystore.location=classpath:RBup.p12

spring.ssl.bundle.jks.rbupbundle.keystore.password=Whatever321

spring.ssl.bundle.jks.rbupbundle.keystore.type=PKCS12


Inside the Tomcat bean, I configure the webserver:

public TomcatServletWebServerFactory tomcatFactory(SslBundles sslBundles) {

return new TomcatServletWebServerFactory() {


@Override

protected TomcatWebServer
getTomcatWebServer(org.apache.catalina.startup.Tomcat tomcat) {

int port = Integer.parseInt(userPrefs.getWebServerPort());

tomcat.enableNaming();

Connector connector = new Connector(
"org.apache.coyote.http11.Http11NioProtocol");

Http11NioProtocol prot = (Http11NioProtocol) connector.getProtocolHandler();

connector.setPort(9000);

connector.setSecure(true);

connector.setScheme("https");

connector.setProperty("SSLEnabled", "true");

SslBundle sslBundle = sslBundles.getBundle("rbupbundle");

SslBundleKey sbk = sslBundle.getKey();

SslStoreBundle ssb = sslBundle.getStores();

SSLHostConfig shc = new SSLHostConfig();

SSLHostConfigCertificate sslHostCert = new SSLHostConfigCertificate();

sslHostCert.setCertificateKeystore(ssb.getKeyStore());

shc.addCertificate(sslHostCert);

shc.setHostName("localhost");

prot.addSslHostConfig(shc);

tomcat.getService().addConnector(connector);

return super.getTomcatWebServer(tomcat);

}

Not sure why I'm getting:

Caused by: java.lang.NullPointerException: Cannot invoke
"org.apache.tomcat.util.net.SSLHostConfig.getProtocols()" because
"this.sslHostConfig" is null

at org.apache.tomcat.util.net.SSLUtilBase.<init>(SSLUtilBase.java:92)

at org.apache.tomcat.util.net.jsse.JSSEUtil.<init>(JSSEUtil.java:61)

at org.apache.tomcat.util.net.jsse.JSSEUtil.<init>(JSSEUtil.java:56)

at
org.apache.tomcat.util.net.jsse.JSSEImplementation.getSSLUtil(JSSEImplementation.java:52)

at
org.apache.tomcat.util.net.AbstractJsseEndpoint.createSSLContext(AbstractJsseEndpoint.java:95)

at
org.apache.tomcat.util.net.AbstractJsseEndpoint.initialiseSsl(AbstractJsseEndpoint.java:70)

at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:207)

at
org.apache.tomcat.util.net.AbstractEndpoint.bindWithCleanup(AbstractEndpoint.java:1271)

at
org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:1284)

at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:622)

at
org.apache.coyote.http11.AbstractHttp11Protocol.init(AbstractHttp11Protocol.java:77)

at org.apache.catalina.connector.Connector.initInternal(Connector.java:1013)

... 21 more


Note: I am new to Tomcat and most of these concepts, also side note if
anyone could chime in to why setCertificateFile

disappeared from SSLHostConfig in the Tomcat API from 9 to 10, it didn't
look like it was deprecated and many

examples use it.

-- 

Adam Michael Danischewski

Software Engineer

Phone: (929) 308-9674

Email: adam.danischew...@gmail.com

Github: http://github.com/AdamDanischewski

Reply via email to