Hi,
I have found critical bug in X509CertificatePolicyCollection.Add() method.
There is missing real addition to the list. In the result, the returned collection is empty and further code, what checks out if it is empty is failing. You have following:
```
public Int32 Add(X509CertificatePolicy entry) {
if (IsReadOnly) { throw new AccessViolationException(Error.E_COLLECTIONCLOSED); }
foreach (X509CertificatePolicy item in _list) {
if (item.PolicyOid.Value == entry.PolicyOid.Value) { return -1; }
}
return _list.Count - 1;
}
```
and it should be:
```
public Int32 Add(X509CertificatePolicy entry) {
if (IsReadOnly) { throw new AccessViolationException(Error.E_COLLECTIONCLOSED); }
foreach (X509CertificatePolicy item in _list) {
if (item.PolicyOid.Value == entry.PolicyOid.Value) { return -1; }
}
////////// here is hange
_list.Add(entry);
///////// up to here
return _list.Count - 1;
}
```
I have changed it on my own copy and is working.
Best Regards,
Stanislaw Wawszczak
ISCG, Poland
Comments: fixed in 3.0
I have found critical bug in X509CertificatePolicyCollection.Add() method.
There is missing real addition to the list. In the result, the returned collection is empty and further code, what checks out if it is empty is failing. You have following:
```
public Int32 Add(X509CertificatePolicy entry) {
if (IsReadOnly) { throw new AccessViolationException(Error.E_COLLECTIONCLOSED); }
foreach (X509CertificatePolicy item in _list) {
if (item.PolicyOid.Value == entry.PolicyOid.Value) { return -1; }
}
return _list.Count - 1;
}
```
and it should be:
```
public Int32 Add(X509CertificatePolicy entry) {
if (IsReadOnly) { throw new AccessViolationException(Error.E_COLLECTIONCLOSED); }
foreach (X509CertificatePolicy item in _list) {
if (item.PolicyOid.Value == entry.PolicyOid.Value) { return -1; }
}
////////// here is hange
_list.Add(entry);
///////// up to here
return _list.Count - 1;
}
```
I have changed it on my own copy and is working.
Best Regards,
Stanislaw Wawszczak
ISCG, Poland
Comments: fixed in 3.0