在openssl签发证书时如何指定16字节序列号?

very80 2012-05-22 10:12:57
在使用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

请问应该从哪个方向入手找解决办法 ?

能有示例代码更好

谢谢 !
...全文
363 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
very80 2012-06-19
  • 打赏
  • 举报
回复
解决问题了.

是php_openssl模块的限制导致的,模块默认只接受int的序列号,即使你传入很大的整数,无论以什么变量类型,都会被强制当做int处理.

最终是通过修改php的openssl模块并重新编译解决的,如果想要编译后的 php_openssl.dll,可以与我联系.

对了,我是在 php5.2.6版本里进行的.
very80 2012-05-22
  • 打赏
  • 举报
回复
[Quote=引用 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 allow……
[/Quote]

3ks for 你的reply
e文水平not非常high,不是非常understand what u post

是不是大概这个意思
php不支持超过10个字符长的数字,超过部分将被截断 ?
后面又说了啥限制
真的有点迷糊了
拜托点解一下 3q all
franzhong 2012-05-22
  • 打赏
  • 举报
回复
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)
franzhong 2012-05-22
  • 打赏
  • 举报
回复
英文不是我写的,我给你查的。但你注意最后一句,不必为int型限制(这个说的模糊了,是可用chat还是可用超出int长度的int,具体你测试一下),但是你那个十六进制头没问题吗。
最后一句说不是int也没问题,不知是不是这样你得改改数据测试一下,先确定能否放入这么长的值支持的类型
qq120848369 2012-05-22
  • 打赏
  • 举报
回复
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类型只有一半长度,高半部分被清零。

21,887

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧