简体   繁体   English

Go - 解码/编码asn.1

[英]Go - decode/encode asn.1

Does anyone know where there is a good example of how to use the asn1 Marshal and Unmarshal funcs in Go? 有谁知道如何在Go中使用asn1 Marshal和Unmarshal函数的好例子?

I'm familiar with the concept of how DER encoding with ASN.1 works, but do not have experience dealing with it directly in code (usually I'm using another library with wraps it - openldap or whatever). 我熟悉如何使用ASN.1进行DER编码的概念,但是没有直接在代码中处理它的经验(通常我正在使用包装它的另一个库 - openldap或其他)。

Yes, I've looked at the documentation ( http://golang.org/pkg/encoding/asn1/ ), which seems to describe a tagging system much like what is available for JSON and XML in Go; 是的,我查看了文档( http://golang.org/pkg/encoding/asn1/ ),它似乎描述了一个标记系统,就像Go中可用于JSON和XML的标记系统一样; however I have yet to find a good practical example of this anywhere for the encoding/asn1 package. 但是我还没有为encoding / asn1包找到一个很好的实例。 (Hm, okay I see the Certificate example in asn1_test.go - anyone know of anything else?) (嗯,好吧,我在asn1_test.go中看到了证书示例 - 任何人都知道其他什么?)

(Overall, I'm trying to implement a very small subset of LDAP (the server side) in Go.) (总的来说,我正在尝试在Go中实现一小部分LDAP(服务器端)。)

UPDATE: My question is flawed by the fact that LDAP uses BER, not DER. 更新:我的问题是因为LDAP使用BER而不是DER。 So encoding/asn.1 isn't going to help. 所以encoding / asn.1无济于事。 In any case, I ended up making this: https://github.com/bradleypeabody/godap (which uses this for BER+ASN1: https://github.com/go-asn1-ber/asn1-ber ) 在任何情况下,我最终都这样做: https//github.com/bradleypeabody/godap (将其用于BER + ASN1: https//github.com/go-asn1-ber/asn1-ber

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM