1
首先,我是Spring-Boot和SSL的新手,但我已經花了好幾天的時間進行研究,基本上試圖獲得配置了客戶端身份驗證的簡單Spring-Boot應用程序。Spring-Boot客戶端認證配置。
我已經建立了一個連接器,像這樣:
private Connector createSslConnector() {
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler();
try {
File keystore = getKeyStoreFile();
File truststore = keystore;
connector.setScheme("https");
connector.setSecure(true);
connector.setPort(sslPort);
protocol.setSSLEnabled(true);
protocol.setKeystoreFile(keystore.getAbsolutePath());
protocol.setKeystorePass("changeit");
protocol.setTruststoreFile(truststore.getAbsolutePath());
protocol.setTruststorePass("changeit");
protocol.setKeyAlias("apitester");
protocol.setClientAuth("need");
return connector;
}
catch (IOException ex) {
throw new IllegalStateException("cant access keystore: [" + "keystore"
+ "] or truststore: [" + "keystore" + "]", ex);
}
}
和控制器,看起來像這樣:
@RequestMapping("/test/{identifier}")
@ResponseBody
ResponseEntity<String> test(HttpServletRequest request, @PathVariable String identifier) {
return new ResponseEntity<String>("hello: " + identifier, HttpStatus.OK)
}
但是,一旦我啓動我的應用程序可以使用瀏覽器來瀏覽到localhost:sslport/hello/test/xxxx,並獲得沒有加載任何類型的客戶端證書的響應。我期待被提示輸入客戶端證書。
你用'https:// localhost:sslport/hello/test/xxxx'試過了嗎? –