为什么不能为x509Certificate创建替代名称?

时间:2019-12-03 03:41:25

标签: c# .net

我正在尝试使用x509Certificate程序集创建新的Microsoft.Hpc.Scheduler.Store

string CAsubject = certSubject;
CX500DistinguishedName distinguishedName = new CX500DistinguishedName();

distinguishedName.Encode("CN=" + CAsubject, X500NameFlags.XCN_CERT_NAME_STR_NONE);

string strRfc822Name = certSubject;

CAlternativeName objRfc822Name = new CAlternativeName();
CAlternativeNames objAlternativeNames = new CAlternativeNames();
CX509ExtensionAlternativeNames objExtensionAlternativeNames = new CX509ExtensionAlternativeNames();

// Set Alternative RFC822 Name 
objRfc822Name.InitializeFromString(AlternativeNameType.XCN_CERT_ALT_NAME_DNS_NAME, strRfc822Name);

// Set Alternative Names 
objAlternativeNames.Add(objRfc822Name);
objExtensionAlternativeNames.InitializeEncode(objAlternativeNames);

最后一行抛出`System.ArgumentException:值不在预期范围内。为什么该方法引发此异常?

0 个答案:

没有答案