gpt4 book ai didi

java - X509证书获取PublicKey

转载 作者:太空宇宙 更新时间:2023-11-04 10:23:06 26 4
gpt4 key购买 nike

我有一个以 Base64 编码的 X509 证书 (RSA) 字符串值(以 MII 开头...)。

我使用 Base64 对其进行解码并创建 X509 证书。

  public X509Certificate getCertificateX509(CertificateFactory factory, InputStream input) throws XX {
try {
return (X509Certificate) factory.generateCertificate(input);
} catch (CertificateException e) {
throw new XX("");
}
}

public CertificateFactory getCertificateFactoryX509() throws XX {
try {
return CertificateFactory.getInstance("X.509");
} catch (CertificateException e) {
throw new XX("");
}
}

我不明白的是,当我执行 x509.getPublicKey().getEncoded() 时,我得到了一个字节数组。

编码为 Base64 我得到一个以 MII 开头的新字符串(与第一个不同),我认为不是 PublicKey 吗?只有以 MII 开头的证书不是吗?

谢谢

最佳答案

我获得的证书是:MIIDKTCCAhGgAwiIBAgIDC5hFMA0GCSqGSIb3DQEBCwUAMEkxCzAJBgNVBAYTAkZSMQ4wDAYDVQQKEwVFQklDUzESMBAGA1UECxMJVFJBTlNQT1JUMRYwFAYDVQQDEw1LaXRVdGlsaXRhaXJlMB4XDTE2MTEwoDA5MTcy NFOXDTIxMTEwNzA5MTcyNFowStelMAkGA1UEBhMCRlIxDjAMBgNVBAoTBUVCSUNTMRIweAYDVQQLEwlUUkFOU1BPUlQxFjAUBgNVBAMTDUtpdFV0aWxpdGFpcmUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDBPci +m6bb1lGrI+rZGmXj8alF8T2eM3WSN7qI5QQi/GhZDmoH8fxUUWSmHtT2Zv9Ar7tG3/1390JN2u7YF8w+yRtdgamF61ANjd7wMRAKhFc2djLZ3OSSPW4la4sUTBnAQftkekQ/0edZagQES7S vqMIkGeIlGvNTxQcpnlLl+Qb8E5y8Akh0LJLUd4Ks5pDjs86LGLtt3Q/T6x9ciNKVjp5/xbwLeRHej6ZUxmjOQLw8CmhDNsJYywWnVAaUu5KR4/4Vc25EebWvo1fVRUOxLv5L7Hx1dzjx WpXHBMbkYCXBKFDr2lMGpGxjQQ815Vhyal1nT93i2593nIiJVG+xAgMBAAGjGjAYMAkGA1UdEwQCMAAwCwYDVR0PBAQDAgZAMA0GCSqGSIb3DQEBCwUAA4IBAQCmv2wm1Nb0IXD6iMnVvFAM2ymSp/5xPB kZEFRPVmIxg+fPtX8xcDYzHX3msAcLIUry5bh6FqT2Mdd11RHdjAMucFO2CB9kjxzxdTcN8MJIkrpCybnh5Ei+O61eqanBNsg45mHxIbiEf2F3QBmZQXKEhK9Ept7lByeFhPzmhY1sD1YRu6mr5i N/J3OdIgLfPPJ6wnrOY8vZ/+qQualM2po7yBzSgzFb4vXW7CRtiIxmHvKOC1nGkI8UPW0kUfY2xjL3gwlQ0EXoCMD4/6E7RDIW9jP5l94eiJTmtBHMP/DMLsYakeFRYjN2hGUQN4p4vQJ 3P1f7hXAIf2QhULffT+J+

以及 Base64 中的 x509.PublicKey.getEncoded() :MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwT3CPpum29ZRqyPq2Rpl4/GpRfE9njN1kje6iOUEIvxoWQ5qB/H8VFFkph7U9mb/QK+7Rt/9d/dCTdru2BfMPskbXYGphetQDY3e8DEQCoRX NnYy2dzkkj1uJWULFEwZwEH7ZHpEP9HnWWWoEBEu0r6jCJBniJRrzU8UHKZ5S5fkG/BOcvaJIdCyS1HeCrOaQ47POixi7bd0P0+sfXIjSly6ef8W8C3kR3o+mVMZozkC8PApoQzbCWMSFp1QG lLuSkeP+FXNuRHm1r6NX1UVDsS7+S+x8dXc48VqVxwTG5GAlwShQ69pTBqRsY0EPNeVYcmpdZ0/d4tufd5yIiVRvsQIDAQAB

关于java - X509证书获取PublicKey,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50870068/

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