将 .cer 转换为 .pem?

将 .cer 转换为 .pem?

我对证书一无所知。我在网上搜索了一下,找到一些相关资料,但都没有对我的情况有帮助。

Red Hat Enterprise Linux ES 版本 4(Nahant 更新 9)

我正在尝试将 .cer(这是一个 CAS 证书)转换为 .pem,并收到以下错误

openssl x509 -inform der -in cas.cer -out cas.pem
unable to load certificate
4419:error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag:tasn_dec.c:959:
4419:error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error:tasn_dec.c:304:Type=X509

我只需运行即可阅读其纯文本

[root@sls32 install]# openssl x509 -in cas.cer -text -noout
Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number: 1331657215 (0x4f5f79ff)
        Signature Algorithm: sha1WithRSAEncryption
        Issuer: C=USA, ST=PA, L=KOP, O=TEST, OU=TEST, CN=TEST.com
        Validity
            Not Before: Mar 13 16:46:55 2012 GMT
            Not After : Dec 27 16:46:55 2016 GMT
        Subject: C=USA, ST=PA, L=Malvern, O=TEST, OU=TEST, CN=TEST.co                                                                                                             m
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
            RSA Public Key: (1024 bit)
                Modulus (1024 bit):
                    00:9d:af:d0:c9:ce:8f:50:88:72:46:34:d3:b3:80:
                    e2:07:61:21:10:1f:b2:81:ce:7f:ad:0b:d3:5c:d3:
                    67:33:b1:20:e7:fc:8b:aa:5e:5a:e5:22:1e:91:c3:
                    e9:29:7e:d0:ea:ec:32:35:b1:b9:b6:d7:ca:e7:7a:
                    21:c3:91:99:fa:14:61:b5:20:31:40:28:cb:93:07:
                    04:dd:dc:56:f0:1e:ac:dd:11:8a:86:db:27:66:e7:
                    31:3f:81:50:17:8c:3d:3a:c5:92:ed:f8:52:e7:cc:
                    44:66:1d:9f:96:a4:1b:9b:ad:13:6a:e3:9c:dc:b8:
                    fb:81:28:76:cd:f7:a5:9d:f7
                Exponent: 65537 (0x10001)
    Signature Algorithm: sha1WithRSAEncryption
        28:68:a0:0b:f1:cc:20:b2:d9:69:a5:1b:4b:fc:83:ad:f8:4d:
        2a:cf:2e:7f:10:7c:60:d0:9b:63:2c:54:be:df:15:32:c7:56:
        b8:56:45:a8:62:af:77:25:b7:17:b0:ef:3f:b9:41:d0:17:90:
        8c:b9:a3:8b:bd:d2:72:89:4f:85:d5:96:c4:7b:9a:e5:ec:89:
        3d:16:c5:9c:70:91:13:79:8b:ef:1d:d0:88:eb:e4:23:e2:6c:
        79:68:bf:69:30:c9:9c:98:d8:1e:a5:b8:b6:ed:07:32:88:c6:
        6e:f2:69:d2:f9:06:22:7a:9a:cd:92:1e:3b:b1:4c:7b:14:4a:
        69:48

有人能给我正确的命令吗?

谢谢

答案1

实际上,.cer 和 .pem 扩展名对我来说相当混乱。从提供的命令输出来看,我认为您的 cas.cer 应该是 bas64 编码的,这是 OpenSSL 接受的格式,无需任何附加参数。

因此,您可以尝试将 cas.cer 复制到 cas.pem(无需转换,只需更改文件名)。

答案2

我以前曾使用过此网站来转换证书,并取得了良好的效果。

https://www.sslshopper.com/ssl-converter.html

相关内容