从密钥库加载证书 [英] loading a certificate from keystore

查看:226
本文介绍了从密钥库加载证书的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从密码保护的密钥库加载证书和密钥,然后将其用于证书验证和数字签名

Load a certificate and keys from keystore which is password protected and then use it for cert verification and digital signing

推荐答案

读取证书真的很琐碎。

To read the certificate is really trivial.

CertificateFactory factory = CertificateFactory.getInstance("X.509");  
X509Certificate certificate = (X509Certificate) factory.generateCertificate(new FileInputStream("file.pem"));  

这是使用标准API(在try / catch中)等,并且已加载您的证书。 >
现在证书的 toString 方法不适合你,因为它只捕获证书的用户视图例如您将使用 println 例如

不能发送证书对象本身?

不确定您的服务器期望您可以查看证书的各种方法

X509证书

This is with standard APIs (in try/catch) etc and you have loaded your certificate.
Now the toString method of certificate is not suitable for you since it just captures the "user's" view of the certificate e.g. you would use it for println for instance
Can't you send the certificate object itself?
Not sure what your server expects so you can look into the various methods of certificate
X509Certificate

这篇关于从密钥库加载证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆