从X509Certificate2在ASN.1符号导出证书 [英] Export a certificate in asn.1 notation from X509Certificate2

查看:620
本文介绍了从X509Certificate2在ASN.1符号导出证书的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我正在学习使用证书的,现在我很好奇,如果有可能从一个 X509Certificate2一个加载证书的ASN.1表示 - 实例。

I'm currently learning working with certificates and now I'm curious, if it is possible to get the ASN.1 notation of a loaded certificate from a X509Certificate2-instance.

我已经找到了导出 - 方法,它工作正常,但我还没有看到一个possibilty改变输出格式的编码 - 这是只有在DER-格式。

I have found the Export-Method and it works fine, however I have not seen a possibilty to change the encoding of the output format - it's only in the DER-format.

是否有可能出口/转换加载的证书作为ASCII ASN.1的证书,像下面的例子:

Is there a possibility to export/convert a loaded certificate as an ASCII ASN.1 certificate, something like in the example below:

Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number: 1 (0x1)
        Signature Algorithm: md5WithRSAEncryption
        Issuer: C=XY....
 ...

或者是有一个转换器,DER转换为纯文本?

Or is there a converter to convert DER to plain text?

推荐答案

我写了一个GTK#工具(在C#),以在几年前这样做。完整的源$ C ​​$ C可从 https://github.com/mono /单工具/树/主/ asn1view

I wrote a Gtk# tool (in C#) to do this a few years ago. The full source code is available from https://github.com/mono/mono-tools/tree/master/asn1view

您可能只需要通用/ prettyPrinter.cs 和的普通/ ASN1De coder.cs ,除非你想为OID的pretty的名字。

You likely need only common/PrettyPrinter.cs and common/ASN1Decoder.cs unless you want pretty names for OIDs.

修改:以上是有点低级别比X.509证书 - 但它会为X.509 CRL,你知道(或没有),可以被嵌入到其他结构证书/ CRL。

EDIT: The above is a bit lower-level than X.509 certificates - but it will work for X.509 CRL and other structures you know (or not) that can be embedded into the certificates/crl.

这篇关于从X509Certificate2在ASN.1符号导出证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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