Java 为Rest使用不同的SSL上下文&;肥皂及;Spring Boot中的JDBC
现在使用SpringBoot,将hsm&MSSQLJDBC&rest&soap服务运行在一个微服务中 MainApplication.javaJava 为Rest使用不同的SSL上下文&;肥皂及;Spring Boot中的JDBC,java,spring-boot,security,hsm,sslcontext,Java,Spring Boot,Security,Hsm,Sslcontext,现在使用SpringBoot,将hsm&MSSQLJDBC&rest&soap服务运行在一个微服务中 MainApplication.java @SpringBootApplication public class MainApplication { @Autowired public Environment env; public static void main(String[] args) { SpringApplication.run(Main
@SpringBootApplication
public class MainApplication {
@Autowired
public Environment env;
public static void main(String[] args) {
SpringApplication.run(MainApplication.class, args);
}
/**
* init keystores
*/
@PostConstruct
public void keystoresInit() {
logger.info("Starting keystores Init");
// INIT Keystore - soap service
KeyStore ks = KeyStore.getInstance(env.getProperty("keyserver.ssl.key-store-type"));
ksFile = new FileInputStream(env.getProperty("keyserver.ssl.key-store"));
ks.load(ksFile, pass);
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
kmf.init(ks, pass);
// INIT Truststore
KeyStore trustKeystore = KeyStore.getInstance(env.getProperty("cacert.ssl.key-store-type"));
tsFile = new FileInputStream(env.getProperty("cacert.ssl.key-store"));
trustKeystore.load(tsFile, env.getProperty("cacert.ssl.key-store-password").toCharArray());
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(trustKeystore);
// INIT SSLContext
SSLContext context = SSLContext.getInstance("TLS");
context.init(kmf.getKeyManagers(), tmf.getTrustManagers(), new SecureRandom());
SSLContext.setDefault(context);
Map<String, String> samplekeys = new HashMap<String, String>();
CustomSSLContext cssc = CustomSSLContext.getInstance(); //which is used for soap services
cssc.initSSLContexts(env.getProperty("keyserver.ssl.key-store"),
env.getProperty("keyserver.ssl.key-store-type"), pass, samplekeys);
} catch (Exception e) {
--
} finally {
--
}
}
/**
* Configuring Hikari datasource and setting password from vault.
* @return
*/
@Bean
@ConfigurationProperties(prefix = "spring.datasource.hikari")
public DataSource dataSource() {
HikariDataSource ds = null;
try {
password = getting from vault;
ds = new HikariDataSource();
ds.setPassword(new String(password));
} catch (Exception e) {
--
} finally {
--
}
return ds;
}
}
java.security
security.provider.1=sun.security.provider.Sun
security.provider.2=sun.security.rsa.SunRsaSign
security.provider.3=com.safenetinc.luna.provider.LunaProvider
security.provider.4=sun.security.ec.SunEC
security.provider.5=com.sun.net.ssl.internal.ssl.Provider
security.provider.6=com.sun.crypto.provider.SunJCE
..etc
问题:
security.provider.1=sun.security.provider.Sun
security.provider.2=sun.security.rsa.SunRsaSign
security.provider.3=com.safenetinc.luna.provider.LunaProvider
security.provider.4=sun.security.ec.SunEC
security.provider.5=com.sun.net.ssl.internal.ssl.Provider
security.provider.6=com.sun.crypto.provider.SunJCE
..etc