我试图找到.keystore
文件和.jks
文件之间的区别,但我找不到它.我知道jks
是"Java密钥库",两者都是存储键/值对的方法.
是否有任何差异或偏好使用一个而不是另一个?
通过查看java.security
我的文件JRE
,我发现默认使用的密钥库类型设置为JKS
.这里有一个可以使用的密钥库类型列表.
是否有推荐的密钥库类型?不同密钥库类型的优缺点是什么?
我一直在:
sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find
valid certification path to requested target
.
.
Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.
ValidatorException: PKIX path building failed: sun.security.provider.
certpath.SunCertPathBuilderException: unable to find valid certification
path to requested target
Run Code Online (Sandbox Code Playgroud)
在搜索如何解决此异常时,我遇到了Keystore
一个我不理解的术语.Keystore简单来说是什么?它与SSL的关系如何?
我使用的是springBootVersion 1.2.0.RELEASE.我正在尝试通过配置我的密钥库和信任库application.properties
.
当我添加以下设置时,我可以让密钥库工作,但不能使用信任库.
server.ssl.key-store=classpath:foo.jks
server.ssl.key-store-password=password
server.ssl.key-password=password
server.ssl.trust-store=classpath:foo.jks
server.ssl.trust-store-password=password
Run Code Online (Sandbox Code Playgroud)
但是,如果我通过gradle添加信任库:
bootRun {
jvmArgs = [ "-Djavax.net.ssl.trustStore=c://foo.jks", "-Djavax.net.ssl.trustStorePassword=password"]
}
Run Code Online (Sandbox Code Playgroud)
它工作得很好.
有没有人用过application.properties
信托商店?
我对Java-NSS库感兴趣,而且我正在阅读Sun的P11指南.我对以下内容感到困惑:
使用PKCS12密钥库和PKCS11密钥库有什么区别?
密钥库只是一个密钥库,对吧?有什么不同吗?它们可以在任何方面互换使用吗?
假设我编写了两个Java应用程序:Ping.jar
并且Pong.jar
它们在两个单独的服务器上部署和运行(Ping.jar
部署到srv-01.myorg.com
并Pong.jar
部署到srv-02.myorg.com
),这两个应用程序需要通过SSL相互通信(双向).我们还假设每个应用程序都有自己的SSL证书.
Ping
和Pong
验证彼此的SSL证书?每个CA是否提供某种我可以使用的RESTful API,比如说HttpClient
?Java是否有自己的证书验证API?是否有我可以使用的开源第三方JAR或服务?当我在网上搜索这个时,我感到很惊讶.
我在Tomcat服务器上安装SSL,并遵循发行人https://knowledge.rapidssl.com/support/ssl-certificate-support/index?page=content&actp=CROSSLINK&id=SO16181的这些说明,并声明:
Verify the following information:
The SSL certificate is imported into the alias with the "Entry Type" of
PrivateKeyEntry or KeyEntry. If not, please import the certificate into
the Private Key alias.
Run Code Online (Sandbox Code Playgroud)
当我导入证书(tomcat)时我正在使用:
keytool -import -trustcacerts -alias your_alias_name -keystore your_keystore_filename
-file your_certificate_filename
Run Code Online (Sandbox Code Playgroud)
但是当我这样做时它导入为trustCertEntry
Keystore type: JKS
Keystore provider: SUN
Your keystore contains 3 entries
primaryca, Jul 26, 2014, trustedCertEntry,
Certificate fingerprint (SHA1): <snip>
tomcat, Jul 26, 2014, trustedCertEntry,
Certificate fingerprint (SHA1): <snip>
secondaryca, Jul 26, 2014, trustedCertEntry,
Certificate …
Run Code Online (Sandbox Code Playgroud) 我正在使用SSL握手连接到URL.为此,我生成了一个.csr文件并将其签名.签名后,我创建了一个my.jks文件,其中包含3个条目
我使用jetty作为服务器,我专门将密钥库和信任库设置为相同的jks文件
-Djavax.net.ssl.keyStore=/home/keystore/my.jks
-Djavax.net.ssl.keyStorePassword=changeit
-Djavax.net.ssl.trustStore=/home/keystore/my.jks
-Djavax.net.ssl.trustStorePassword=changeit
Run Code Online (Sandbox Code Playgroud)
它工作正常.但这是正确的方法吗?我认为密钥库应该包含客户端证书和私钥,信任库应该包含CA. 但是当我尝试这样做时,我得到以下错误.
"javax.net.ssl.SSLHandshakeException:sun.security.validator.ValidatorException:PKIX路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到所请求目标的有效证书路径"
请就此提出建议.
我正在本地测试客户端和服务器之间的SSL通信.所以我使用OpenSSL命令生成证书.在cacert文件中添加了此证书.还生成.p12文件.
我在服务器和客户端使用相同的.p12文件.这是服务器代码
Server server = component.getServers().add(Protocol.HTTPS, port);
Series<Parameter> params = server.getContext().getParameters();
params.add("keystorePath", ".p12 file path");
params.add("keystoreType", "PKCS12");
params.add("needClientAuthentication","true");
component.getDefaultHost().attach("", "/AA"), new AAClass());
component.start();
Run Code Online (Sandbox Code Playgroud)
这是客户端代码:
Client client = trustAllCerts();
clientResource = new ClientResource(url);
clientResource.setNext(client);
try{
clientText = clientResource.post"");
}
catch(ResourceException e){
e.printStackTrace();
}
public Client trustAllCerts() {
Client client = null;
try {
client = new Client(new Context(), Protocol.HTTPS);
Context context = client.getContext();
final SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
context.getAttributes().put("sslContextFactory", new SslContextFactory() {
public void init(Series<Parameter> parameters) {
}
public SSLContext createSslContext() …
Run Code Online (Sandbox Code Playgroud) 我正在尝试在两个Java项目之间建立安全连接,但我收到了SSLHandshakeException(没有共同的密码套件).这是在两侧创建套接字的方法:
客户:
private SSLSocket getSocketConnection() throws SSLConnectionException {
try {
/* Load properties */
String keystore = properties.getProperty("controller.keystore");
String passphrase = properties.getProperty("controller.passphrase");
String host = properties.getProperty("controller.host");
int port = Integer.parseInt(properties
.getProperty("controller.port"));
/* Create keystore */
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
keyStore.load(new FileInputStream(keystore), passphrase.toCharArray());
/* Get factory for the given keystore */
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(keyStore);
SSLContext ctx = SSLContext.getInstance("SSL");
ctx.init(null, tmf.getTrustManagers(), null);
SSLSocketFactory factory = ctx.getSocketFactory();
return (SSLSocket) factory.createSocket(host, port);
} catch (Exception e) {
throw new SSLConnectionException(
"Problem connecting …
Run Code Online (Sandbox Code Playgroud) java ×7
ssl ×7
keystore ×3
jsse ×2
keytool ×2
security ×2
jks ×1
nss ×1
pkcs#11 ×1
pkcs12 ×1
properties ×1
restlet ×1
rsa ×1
spring-boot ×1
truststore ×1