X509Store.Certificates 的序列是如何确定的?

huangapple go评论72阅读模式
英文:

How is the sequence for X509Store.Certificates decided?

问题

我正在使用一个证书存储,并对证书序列的计算方式感到困惑。

根据X509Store.Certificates的文档,有以下提及:

> 每次调用该属性时都会重新计算此快照,因此不建议在迭代函数内部使用此属性。

我想知道属性中证书的顺序是如何确定的。
我检查了一下,似乎这个顺序不是基于证书的颁发或颁发日期。
我有一些直接使用证书索引的执行,想确认我是否能确保我所操作的证书是正确的。

英文:

I am working with a cert store and am confused on how the certificates sequence is calculated.

As per documentation for X509Store.Certificates, it is mentioned in remark that

> This snapshot is recalculated each time the property is called, so the
> use of this property inside an iterative function is not recommended.

I wanted to know how is the sequence of certificates decided in the property.
I checked and it seems the sequence is not based on certificate issued to or issued date.
I have some execution that works directly with indexes of the certificates and wanted to confirm if I can guarantee the certificate I am working is correct.

答案1

得分: 2

不应依赖X509Store.Certificates集合中的证书索引,因为它不是确定性的,而是依赖于不同来源中证书的顺序,然后合并为结果列表。而是应该使用X509Certificate2Collection.Find方法在集合中查找所需的证书。

英文:

You shall not rely on certificate index in X509Store.Certificates collection because it is not deterministic and depends on certificate order in different sources which then combined into a resultant list. You shall use X509Certificate2Collection.Find method to look for required certificate in the collection instead.

huangapple
  • 本文由 发表于 2023年3月31日 19:47:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/75898182.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定