<p>I need to parse X509 certificate from a hex string like this:</p>
<pre><code>string strCert = `30 82 06 27 30 82 05 0f a0 03 02 01 02 02 10 19
98 5b 10 01 85 43 2b bd 9e 78 12 a1 fb e9 2f 30...
</code></pre>
<p>Go provides <em>x509.ParseCertificates</em> to do that, but I don't know how to correctly convert the string hex to a <em>byte[]</em>. Can someone help?</p>
<p>Thanks in advance</p>
<p>Kind regards</p>
<hr/>**评论:**<br/><br/>Sphax: <pre><p>Use <a href="https://golang.org/pkg/encoding/hex/#DecodeString" rel="nofollow">hex.DecodeString</a></p></pre>gohacker: <pre><p>They probably need to delete the whitespace first, using <a href="https://golang.org/pkg/strings/#Replace" rel="nofollow">strings.Replace</a> or smth like that.</p></pre>rabbitstack: <pre><p>Thank you guys. That did it.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
0 回复
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传