在使用openssl函数签发证书时遇到了点问题,项目明确要求需要指定16字节证书序列号,形如 0x4C530000000000000100020004000009,其中最后3个字节是动态变化的,在使用 openssl_csr_sign 函数时遇到了麻烦.resource openssl_csr_sign ( mixed $csr , mixed $cacert , mixed $priv_key , int $days [, array $configargs [, int $serial=0 ]] )最后一个参数可以指定序列号,但普通的int不能支持这么大的整数,曾经尝试过使用 sprintf('%s', $n),尝试过直接传入文本,要么只写进一个字节,要么为0请问应该从哪个方向入手找解决办法 ?能有示例代码更好谢谢 !

解决方案 »

  1.   

    Description:
    ------------
    The  Certificat  defintion OpenSSL   allows for  numerical serial numbers up to 
    20 positions or more..    
    In PHP  there is  build  in integer   rerstriction only allowing  half the serial
    numbers .....   higher  numbers  have a cleared  part......The serial needs to be  numerical no problem  but it need not be an integer
    or limited by that  (allow  higher numbers)
      

  2.   


    3ks for 你的reply
    e文水平not非常high,不是非常understand what u post是不是大概这个意思
    php不支持超过10个字符长的数字,超过部分将被截断 ?
    后面又说了啥限制
    真的有点迷糊了
    拜托点解一下 3q all
      

  3.   

    The Certificat defintion OpenSSL allows for numerical serial numbers up to  
    20 positions or more..   
    In PHP there is build in integer rerstriction only allowing half the serial
    numbers ..... higher numbers have a cleared part......
    貌似意思是默认openssl支持20位长度的整数,但php的内置int类型只有一半长度,高半部分被清零。
      

  4.   

    英文不是我写的,我给你查的。但你注意最后一句,不必为int型限制(这个说的模糊了,是可用chat还是可用超出int长度的int,具体你测试一下),但是你那个十六进制头没问题吗。
    最后一句说不是int也没问题,不知是不是这样你得改改数据测试一下,先确定能否放入这么长的值支持的类型
      

  5.   

    解决问题了.是php_openssl模块的限制导致的,模块默认只接受int的序列号,即使你传入很大的整数,无论以什么变量类型,都会被强制当做int处理.最终是通过修改php的openssl模块并重新编译解决的,如果想要编译后的 php_openssl.dll,可以与我联系.对了,我是在 php5.2.6版本里进行的.