如何获取给定 CSR 的密钥大小(以位为单位)?
我正在.net(c#)中编写一个程序,使用Liping Share ASN1 Editor,它可以解码给定的 CSR 非常好。
所以,我的问题是:如何获取给定 CSR 的位大小? (我想测试它是否是1024或更高)
我已经尝试过 .net X509Certificate 类,但该类仅适用于证书,不适用于 CSR。
无法使用 Java 类或解析包含 CSR 解码器的网页。 (虽然我已经认为这比解决问题要容易得多)
也许解决方案很简单,我只是不明白,但如果有人能给我建议,我将非常感激! (这两天谷歌太多了!!)
I`m writing a program in .net(c#), using the Liping Share ASN1 Editor, which decodes the given CSRs very well.
So, my problem is: How do I get the bit size of a given CSR? (i want to test if it is 1024 or higher)
I already tried the .net X509Certificate class, but that only function with certificates, not with CSRs.
There is no possibility to use a Java class or parse a webside which contains a CSR Decoder. (although i already thought that would be much easier than solve the problem otherwise)
Maybe the solution is very simple and I just don´t get it, but if anyone can give me an advice, I would really appreciate it! (too much Google for the last two days!!)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不熟悉 C#,但知道 PHP,首先需要从 CSR 获取 CSR 的公钥,然后检查公钥中的密钥大小。
返回的是包含位大小的公钥信息的数组。
注意:我通过测试和广泛的研究发现 JSmitty 提到的方法并不可靠。
I'm not familiar with c# but know with PHP you first need to get the CSR's public key from the CSR, then check the keysize in the public key.
The return is an array of public key info including the bit size.
NOTE: I have found from testing and extensive research that the method mentioned by JSmitty is not reliable.
这似乎很简单:只需查看 CSR 本身的前几个字符即可。如果以MIIC开头,则为512位,MIID为1024位。这是一个更简单的观点:
我还没有验证(根据规范文档)这是否 100% 可靠,但它似乎是正确的,得到我所做的基于示例的研究的支持(发现 在多个网站上以及根据我生成不同位数的 CSR 的个人经验)。
It seems to be pretty simple: just look at the first few characters of the CSR itself. If it starts with MIIC, it's 512-bit, MIID is 1024-bit. Here's a simpler view:
I haven't gotten to verify (by terms of a spec document) that this is 100% reliable, but it seems to hold true, supported by the example-based research I've done (found on several sites and from my personal experience generating CSRs with differing numbers of bits).