如何在 Windows Azure 上获取代码证书

发布于 2024-11-01 10:08:16 字数 255 浏览 6 评论 0原文

我正在尝试创建我们自己的 WIF 身份提供程序并在 Azure 上运行它,但在尝试自动生成联合元数据时我遇到了困难。

此行似乎不适用于 Azure:

CertificateUtil.GetCertificate(StoreName.My, StoreLocation.LocalMachine, signingCertificateName);

证书已上传到 Azure,我怎样才能获得它?

谢谢

I'm trying to create our own WIF Identity Provider and run it on Azure but I'm struggling when trying to automatically generate the Federation Metadata.

This line does not appear to work on Azure:

CertificateUtil.GetCertificate(StoreName.My, StoreLocation.LocalMachine, signingCertificateName);

The certificate is uploaded to Azure, how can I get hold of it?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

枕梦 2024-11-08 10:08:16

作为其他答案的细微变化,如果您只想获得一个证书而不是遍历所有证书,您可以执行以下操作:(

var store = new X509Store(StoreName.My, StoreLocation.LocalMachine);

store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);

X509Certificate2Collection matchedCertificates =
     store.Certificates.Find(X509FindType.FindBySubjectName, signingCertificateName, true);

if (matchedCertificates.Count > 0)
{
    myCertificate = matchedCertificates[0]; 
}

这也不是 Azure 特定的)

As a slight variation on other answers, if you just want to get one certificate rather than iterate through all of them you could do something like this:

var store = new X509Store(StoreName.My, StoreLocation.LocalMachine);

store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);

X509Certificate2Collection matchedCertificates =
     store.Certificates.Find(X509FindType.FindBySubjectName, signingCertificateName, true);

if (matchedCertificates.Count > 0)
{
    myCertificate = matchedCertificates[0]; 
}

(which also is not Azure specific)

绝不服输 2024-11-08 10:08:16

试试这篇博文:
http://blogs.msdn.com/b/jnak/archive/2010/01/29/installing-certificates-in-windows-azure-vms.aspx

它建议如下代码:

X509Certificate2Collection selectedCerts = new X509Certificate2Collection();

X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
store.Open(OpenFlags.OpenExistingOnly | OpenFlags.ReadOnly);
foreach (X509Certificate2 cert in store.Certificates)
{
    // do stuff with cert
}

Try this blog post:
http://blogs.msdn.com/b/jnak/archive/2010/01/29/installing-certificates-in-windows-azure-vms.aspx

It suggests code like:

X509Certificate2Collection selectedCerts = new X509Certificate2Collection();

X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
store.Open(OpenFlags.OpenExistingOnly | OpenFlags.ReadOnly);
foreach (X509Certificate2 cert in store.Certificates)
{
    // do stuff with cert
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文