Java Code Examples for org.springframework.boot.context.embedded.Ssl#setKeyStore()
The following examples show how to use
org.springframework.boot.context.embedded.Ssl#setKeyStore() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebServerConfiguration.java From youkefu with Apache License 2.0 | 6 votes |
@Bean public EmbeddedServletContainerFactory createEmbeddedServletContainerFactory() throws IOException, NoSuchAlgorithmException { TomcatEmbeddedServletContainerFactory tomcatFactory = new TomcatEmbeddedServletContainerFactory(); tomcatFactory.addConnectorCustomizers(new UKeFuTomcatConnectorCustomizer(maxthread, maxconnections)); File sslFile = new File(path , "ssl/https.properties") ; if(sslFile.exists()){ Properties sslProperties = new Properties(); FileInputStream in = new FileInputStream(sslFile); sslProperties.load(in); in.close(); if(!StringUtils.isBlank(sslProperties.getProperty("key-store")) && !StringUtils.isBlank(sslProperties.getProperty("key-store-password"))){ Ssl ssl = new Ssl(); ssl.setKeyStore(new File(path , "ssl/"+sslProperties.getProperty("key-store")).getAbsolutePath()); ssl.setKeyStorePassword(UKTools.decryption(sslProperties.getProperty("key-store-password"))); tomcatFactory.setSsl(ssl); } } return tomcatFactory; }
Example 2
Source File: SslServletContainerCustomizer.java From haven-platform with Apache License 2.0 | 6 votes |
@Override public void customize(ConfigurableEmbeddedServletContainer container) { KeystoreConfig cert = configureKeystore(); if(cert == null) { log.debug("Ssl is not enabled due to no any configured keystore."); return; } String keystorePath = cert.getKeystore().getAbsolutePath(); log.debug("Configure ssl with {} keystore.", keystorePath); Ssl ssl = new Ssl(); ssl.setEnabled(true); ssl.setKeyStore(keystorePath); ssl.setKeyStorePassword(cert.getKeystorePassword()); ssl.setKeyPassword(cert.getKeyPassword()); container.setSsl(ssl); }