在通过httpClient发送给服务提供商之前,从“es-staging.crt”证书中签名Xml

问题描述 投票:0回答:1

我有来自服务提供商的es-staging.crt文件我正在使用的服务。我需要使用此es-staging.crt证书发送带签名的xml。我不知道如何实现它。

如何在java语言中解决这个问题?

我已经通过java代码读取了证书信息,如下所示。

String cerPath = "E:/configDirectory/es-staging.crt";
fileInputStream = new FileInputStream(new File(cerPath));
CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
x509Certificate = (X509Certificate) certificateFactory.generateCertificate(fileInputStream);
publicKey = x509Certificate.getPublicKey();
expiryDate = x509Certificate.getNotAfter();

System.out.println("public key : "+publicKey);
System.out.println("expiryDate : "+expiryDate);

System.out.println("--> Subject: " + x509Certificate.getSubjectDN().getName());

System.out.println("--> Issuer: " + x509Certificate.getIssuerDN().getName());

我只有这张es-staging.crt证书。

java algorithm public-key-encryption private-key sign
1个回答
1
投票

您无法使用X509公钥签署文档。您需要访问私钥。

© www.soinside.com 2019 - 2024. All rights reserved.