gpt4 book ai didi

java - 为 SOAP header 生成证书

转载 作者:行者123 更新时间:2023-12-01 14:15:27 25 4
gpt4 key购买 nike

当我尝试生成代码时:

Certificate cert;

InputStream path = new FileInputStream(TRUSTSTORE_LOCATION);
KeyStore ks = KeyStore.getInstance("JKS");
ks.load(path, TRUSTSTORE_PASS.toCharArray());

// jak argument podaje sie certyfikat ktory jest zawarty w pliku trustory.jks
cert = ks.getCertificate("xxxx");
binarySecurityTokenElement.addTextNode(new BASE64Encoder().encode(cert.getEncoded()));
//kpg = KeyPairGenerator.getInstance("DSA");
kpg = KeyPairGenerator.getInstance("RSA");

输出为:

<wsse:BinarySecurityToken EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" 
Id="X509-7E20D88DE75F0EAADA137595678499810"
ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3">
MIIDXDCCAkSgAwIBAgIEUFbpiDANBgkqhkiG9w0BAQUFADBwMQswCQYDVQQGEwJQTDEQMA4GA1UE&#13;
CBMHVW5rbm93bjENMAsGA1UEBxMETG9kejEVMBMGA1UEChMMQU1HLm5ldCBTLkEuMRUwEwYDVQQL&#13;
[...]

行尾有这个“ ;”,怎么删除??

最佳答案

Base64Converter base = new Base64Converter();
String encodeCertyficate = base.encode(cert.getEncoded());
encodeCertyficate = encodeCertyficate.replace("\r", "").replace("\n", "");
binarySecurityTokenElement.addTextNode(encodeCertyficate);

关于java - 为 SOAP header 生成证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18145723/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com