将证书文件存储在 SQL Server 表中
在哪里可以找到有关在 SQL Server 表中存储证书“.cer”和“pfx”的信息?
我可以将其存储为字符串还是需要将其保存为二进制数据?
Where can I find information on storing a certificate ".cer" and "pfx" in a SQL Server table?
Can I just store it as a string or does this need to be saved as binary data?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需存储为
varbinary(max)
(您可以存储最多 2GB-1 字节的任何内容)编辑:为了限定轻微的轻率,它是证书的事实与 SQL Server 无关,就像它不会一样'无法识别 Word 文档或 PDF:它们都是二进制数据
Just store as
varbinary(max)
(You can store anything in that upto 2GB-1 bytes)Edit: to qualify the slight flippancy, the fact it is a certificate is irrelevant to SQL Server like it won't recognise a Word document or PDF as such: it's all binary data
PFX 是二进制格式。 “规范”CER 文件也应该是二进制格式(DER 编码的二进制数据),尽管某些应用程序将 base64 编码的证书甚至 PEM 包装的证书放在那里。
鉴于它们是二进制的,您可以将它们存储在 BLOB 中,也可以对其进行 base64 编码,然后将它们存储为字符串。但后者没有意义,因为 Base64 编码的数据会占用表中更多的空间。
PFX is binary format. "Canonical" CER file should be a binary format too (DER-encoded binary data), though some applications put base64-encoded certs or even PEM-wrapped certs there.
Given that they are binary, you can store them either in BLOB or base64-encode them and then store them as string. But the latter doesn't make sense as base64-encoded data will consume more place in the table.