具有主题UID的X509证书 [英] X509 Certificate with Subject UID

查看:140
本文介绍了具有主题UID的X509证书的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从这样的字符串中加载证书:

I am loading a certificate from string like this:

public static void Test()
{
    byte[] arrayCertificate;
    arrayCertificate = Convert.FromBase64String("CERT_STRING");
    X509Certificate2 clientCertificateFromXml = new X509Certificate2(arrayCertificate);
    Console.Write(clientCertificateFromXml);
    Console.ReadKey();
}

但是此证书没有主题唯一标识符"看看这个:

But this certificate doesn't have a "Subject Unique Identifier" Take a look at this:

http://en.wikipedia.org/wiki/X.509 (证书结构)的部分

我想知道如何从我的.NET代码中读取该值(我发现我可以获取SerialNumber,Thumbprints等,但是任何地方都没有Subject UID).

And I want to know how can I read that value from my .NET code (I looked that I can get SerialNumber, Thumbprints and others but there is no Subject UID anywhere).

此外,如果有人可以共享一个openssl命令以将该证书的UID包括在内,我将不胜感激:-)(pfx一个)

Also, I will really appreciate If anyone can share an openssl command to include this UID for the certificate :-) (pfx one)

推荐答案

我想知道如何从.NET代码中读取该值

And I want to know how can I read that value from my .NET code

IIRC在.NET BCL中未公开,无论是 X509Certificate 还是更新的(更好但仍不完整) X509Certificate2 .

IIRC this is not exposed in the .NET BCL, either from X509Certificate or the newer (better but still incomplete) X509Certificate2.

但是您可以使用 Mono.Security 程序集(或只是您想要的代码),请来自 Mono 项目.它是开放源代码,已获得MIT.X11许可,并包含自己的 X509Certificate .

But you can use Mono.Security assembly (or just the code you want from it), from the Mono project. It's open source, MIT.X11 licensed and it includes it's own X509Certificate.

此版本公开了X.509证书中的几乎所有内容,包括

This version expose just about everything in X.509 certificates, including a SubjectUniqueIdentifier property.

如果任何人都可以共享一个openssl命令以包括证书的此UID,我将不胜感激

I will really appreciate If anyone can share an openssl command to include this UID for the certificate

我不记得openssl了,但是您可以使用Mono.Security的 X509CertificateBuilder 创建自己的证书.有关示例,请参见Mono的 makecert 工具源代码.

I do not recall for openssl... but you can use the X509CertificateBuilder from Mono.Security to create your own certificates. See Mono's makecert tool source code for an example.

免责声明:我写了代码:-)

这篇关于具有主题UID的X509证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆