如何获取给定 CSR 的密钥大小(以位为单位)?

发布于 2024-10-15 20:12:32 字数 351 浏览 2 评论 0原文

我正在.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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

十秒萌定你 2024-10-22 20:12:32

我不熟悉 C#,但知道 PHP,首先需要从 CSR 获取 CSR 的公钥,然后检查公钥中的密钥大小。

openssl_pkey_get_details(openssl_csr_get_public_key($your_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.

openssl_pkey_get_details(openssl_csr_get_public_key($your_csr));

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.

乖乖哒 2024-10-22 20:12:32

这似乎很简单:只需查看 CSR 本身的前几个字符即可。如果以MIIC开头,则为512位,MIID为1024位。这是一个更简单的观点:

Beginning    Number of
Characters  bits in CSR
----------  -----------
MIIC        512-bits
MIID        1024-bits
MIIE        2048-bits
MIIG        4096-bits
MIIK        8192-bits
MIIS        16384-bits

我还没有验证(根据规范文档)这是否 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:

Beginning    Number of
Characters  bits in CSR
----------  -----------
MIIC        512-bits
MIID        1024-bits
MIIE        2048-bits
MIIG        4096-bits
MIIK        8192-bits
MIIS        16384-bits

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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文