我正在尝试执行HDInsight的工作。
以下是获取证书代码,并在其中引发异常

X509Certificate2 cert= store.Certificates.Cast<X509Certificate2>().First(item => item.FriendlyName == certFriendlyName);"

// Get the certificate object from certificate store using the friendly name to identify it

 X509Store store = new X509Store();
 store.Open(OpenFlags.ReadOnly);
 X509Certificate2 cert=   store.Certificates.Cast<X509Certificate2().
 First(item => item.FriendlyName == certFriendlyName);
 JobSubmissionCertificateCredential creds =new JobSubmissionCertificateCredential (new Guid(subscriptionID), cert, clusterName);

我使用了以下命名空间:
使用系统;
使用System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Threading;
using System.Security.Cryptography.X509Certificates;
using Microsoft.WindowsAzure.Management.HDInsight;
using Microsoft.Hadoop.Client;
using System.Linq;

最佳答案

您得到什么异常(exception)?

该代码正在使用当前用户存储,您的证书在当前用户存储中吗?

我建议您首先列出所有证书的友好名称,以验证其是否存在。

08-04 11:53