phpseclib无法读取包含guillemet括号的CSR字段

时间:2018-05-17 06:55:52

标签: php phpseclib

以下是我在organizationalUnit OU字段值<this is a test>中使用括号创建的示例CSR,phpseclib似乎无法返回此值。有没有解决这个问题?

-----BEGIN CERTIFICATE REQUEST-----
MIICqzCCAZMCAQAwaDEVMBMGA1UEAwwMdGVzdGNzci50ZXN0MQ0wCwYDVQQKDAR0
ZXN0MRkwFwYDVQQLDBA8dGhpcyBpcyBhIHRlc3Q+MQswCQYDVQQIDAJOWTELMAkG
A1UEBwwCTlkxCzAJBgNVBAYMAlVTMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
CgKCAQEAgqK3dSpXidA5DaKuIG7cg3ioKcyWXWCRdms/pUz+7FvDO1qUtdZoogXy
e5Vty+lHqxYsHOuqjt/HjVYEkQW5jV/e5i8BUdZ/HyBCLrVxhrOBCKYt5pTl5zE3
8Zw6zS7tL8ZVjoo3HvoFRp/R+IGjpNBLyhB4M7oyUBiomyQhuLxc1e/dq9/f7S1k
El66XOrLf15ghjRImVT4N4APmvV1eSojGINFG+ILST0iBSTz2tKPsPPVwO9b59nh
Prrdhzz7tPmn9qooVzVqRvUtZan3dNmtG3ZGR1v0wU0Psox6go/LgECagSXeXBYN
cctuqOkcfXxL2n+dLlkFUDS3qhYoGQIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQAk
jzYjenq3IVUj5jKhC0MPRvSFnazun6H35pVLXqES8Zn3kN6bCqmZTAjDDtRP0ohx
jCk0FW1lkvQVn+/tYrX/kghclZhHVXFO47B0Li3KMm/Gg9DAHxud2xCHwJOcCWDQ
t/RXTLjq7n8A7A4/enfWiSlMGeSA6o5zynSCbzRzkjx+CzCfwunOKEdhARaouxqZ
Z3lXWhoH1QcBy2SS90mS8XiqFaXwDGYz8c8PK5JBP01mH/MuAgVsOONDSz/nEFzR
MC7l/ATdyqQf/lOegM+Rr/K5ox5+kdxAnBx0SrvvGB1iLTlVy/hyrjK4GIQaTZPC
fixw9o3Nje4+FsBnW6vP
-----END CERTIFICATE REQUEST-----

使用phpseclib解析字段时,我得到以下输出:

[2] => Array
    (
        [0] => Array
            (
                [type] => id-at-organizationalUnitName
                [value] => Array
                    (
                        [utf8String] => 
                    )

            )

    )

通过命令行进行本地openssl读取OU字段没有问题。

openssl req -text -noout -verify -in ouissue.txt
verify OK
Certificate Request:
    Data:
        Version: 0 (0x0)
        Subject: CN=testcsr.test, O=test, OU=<this is a test>, ST=NY, L=NY, C=US
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
                Public-Key: (2048 bit)
                Modulus:
                    00:82:a2:b7:75:2a:57:89:d0:39:0d:a2:ae:20:6e:
                    ....
                    1c:7d:7c:4b:da:7f:9d:2e:59:05:50:34:b7:aa:16:
                    28:19
                Exponent: 65537 (0x10001)
        Attributes:
    Signature Algorithm: sha256WithRSAEncryption
         24:8f:36:23:7a:7a:b7:21:55:23:e6:32:a1:0b:43:0f:46:f4:
         ....

1 个答案:

答案 0 :(得分:1)

通过使用htmlentities();显示脚本标记解决,否则浏览器只是将其读取为html。

e.g。 echo htmlentities($x509->getDNProp('OU'));