如何查找 X509 序列号
我正在构建需要 wse 安全性的肥皂消息,并且出于某种原因,客户端需要 KeyInfo、主题和序列号。但 x509 显示的序列号是十六进制,不符合 X509SerialNumber 节点(整数)的 xsd 要求。我读到这需要发行者序列号,但它不是证书的一部分。这是一个自签名证书。如何确定序列号是什么?
请不要告诉我使用 WCF。如果我能使用它,我会的。我知道 WCF 会让事情变得更容易,我持有 WCF 的 MCTS。
I'm building soap message which requires wse security and for some reason, the client requires KeyInfo, subject and serial #. but the serial # displayued for the x509 is hex and doesn't fit the xsd requirements for X509SerialNumber node which is integer. I've read that this needs to the the issuer serial # but it isn't part of the cert. This is a self signed certificate. How can I determine what the serial # is?
Please DO NOT tell me to use WCF. If I could use it, I would. I know WCF would make it easier, I hold an MCTS for WCF.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
证书只有一个序列号字段,并且是二进制数据。发行人可以在那里放置任何东西。事实上,序列号被视为一个非常大的整数,但是如果您只检查保存该数字的字节数组,那么该数字看起来就像一个二进制文件。所以你需要将这个值视为一个巨大的数字并将其转换为“可读”的形式。例如。如果您有包含 FF 00 FF 00(4 个字节)的 4 字节长字节数组,则字符串表示形式将为“4278255360”
更新:我的上述解释适用于 XMLDSig 和 XMLEnc 标准。在其他标准中(或仅用于显示目的),可以使用其他格式(例如 base64、base16 编码等)。
There's only one serial number field of the certificate and it's is binary data. The issuer can put anything there. In fact, serial number is treated as a very large integer number, but such number will look like a binary if you just inspect the byte array that holds the number. So you need to treat this value as a huge number and convert it to "readable" form. Eg. If you have 4-byte-long byte array that contains FF 00 FF 00 (4 bytes), the string representation will be "4278255360"
Update: my above explanation applies to XMLDSig and XMLEnc standards. In other standards (or just for display purposes) other formats can be used (such as base64, base16 encoding etc.).
我找到了我需要的东西。 http:// /www.dotnetmonster.com/Uwe/Forum.aspx/dotnet-security/2875/Manually-computing-sha1-digest-of-reference-having
只需添加一些代码。 X509ChainElement.Certificate.GetSerialNumberString() 给了我我需要的东西,我不需要计算任何东西。
这是我现在使用的代码
I found what I needed. http://www.dotnetmonster.com/Uwe/Forum.aspx/dotnet-security/2875/Manually-computing-sha1-digest-of-reference-containing
Just needed to add some code. the X509ChainElement.Certificate.GetSerialNumberString() gives me what I need and I don't have to calc anything.
Here is the code I'm now using