Home > Back-end >  The correct springboot2 configuration HTTPS Protocol handler start failed
The correct springboot2 configuration HTTPS Protocol handler start failed

Time:10-28

According to the steps of online
1, Mr Into certificate
2, the certificate on the resources under the
3, configure SSL
4, increase the config class

Done, a start, an error
Org. Apache. Catalina. LifecycleException: Protocol handler start failed

Org. Springframework. Boot. Web. Embedded. Tomcat. ConnectorStartFailedException: Connector configured to listen on port 8443 failed to start

Solve the error, comment out the SSL configuration, restart, is successfully launched, but no HTTPS role

The following post detailed operation


Generate a certificate
 
Keytool genkey - alias. Your alias - keypass yourpass1 keyalg RSA - keysize 3650-2048 - gnosis.xml.validity keystore E:/httpsKeys/keystore. Keystore - 121233
the storepass



Yml configuration, port 8080808 1844, or 18080... Whatever will be an error, only comment the SSL configuration can start
 
Server:
Port: 8443
Tomcat:
Uri - encoding: utf-8
The servlet:
The context path:/
SSL:
The key - store: the classpath: keystore. # keystore certificate name
# key - store: the classpath: keystore keystore
The key - store - password: 121233 # keystore password
# # key - password: yourpass1 springboot2.0 don't need to configure the T - T
The key - store - type: as PKCS12
The key - alias: your alias




The configuration class
 
Package com. KFT. Automobile. Config. HTTPS.

The import org. Apache. Catalina. Context;
The import org. Apache. Catalina. Connector. The connector;
Import org, apache tomcat. Util. Descriptor. Web. SecurityCollection;
Import org, apache tomcat. Util. Descriptor. Web. SecurityConstraint;
The import org. Springframework. Boot. Web. Embedded. Tomcat. TomcatServletWebServerFactory;
The import org. Springframework. Context. The annotation. Bean;
The import org. Springframework. Context. The annotation. The Configuration;

@ Configuration
Public class HttpsConnector {

@ Bean
Public Connector Connector () {
Connector Connector=new Connector (" org. Apache. Coyote. Http11. Http11NioProtocol ");
The setScheme (" HTTP ");
The setPort (8081);//the same whether 8080 or 8081
The setSecure (false);
The setRedirectPort (8443);//
Return the connector.
}

@ Bean
Public TomcatServletWebServerFactory TomcatServletWebServerFactory () {
TomcatServletWebServerFactory tomcat=new TomcatServletWebServerFactory () {
@ Override
Protected void postProcessContext Context (Context) {
SecurityConstraint SecurityConstraint=new SecurityConstraint ();
SecurityConstraint. SetUserConstraint (" CONFIDENTIAL ");
SecurityCollection collection=new SecurityCollection ();
Collection. AddPattern ("/* ");
SecurityConstraint. AddCollection (collection);
The context. AddConstraint (securityConstraint);
}
};
Tomcat. AddAdditionalTomcatConnectors (connector ());
Return the tomcat;
}
}






For help, really don't understand what the reason, says online ports occupied, no matter use,
Because I can start a comment out the SSL configuration, a open, no problem, no matter in which port

CodePudding user response:

When you make the certificate is not specified as PKCS12, the default should be JKS, you have to do is change as PKCS12 to JKS, or generate a certificate specified - storetype as PKCS12
  • Related