Windows Azure的管理库在网上工作认证错误 [英] Windows Azure Management Libraries Certification Error on Web Jobs

查看:169
本文介绍了Windows Azure的管理库在网上工作认证错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建了一个Azure的网络工作控制台这是指的Windows Azure管理库。 我试图通过使用公共设置的方法来验证我的应用程序。

程序工作正常在我的地方,但未能在Azure上的Web乔布斯与X509Certificates的错误。

这是我做到了Web作业程序。

  1. 下载发布的设置文件 https://windows.azure.com/download/ publishprofile.aspx

  2. 在控制台应用程序,创建凭证通过复制和;从设置文件粘贴subscriptionId和证书的字符串。

     新CertificateCloudCredentials(
        subscriptionId,
        新509Certificate2(Convert.FromBase64String(base64En codedCertificate)));
     

  3. 部署和放大器;试图在Azure网络招聘按需运行。

  4. 错误

     在System.Security.Cryptography.CryptographicException.ThrowCryptographicException(的Int32小时)
    在System.Security.Cryptography.X509Certificates.X509Utils._LoadCertFromBlob(字节[] RAWDATA,IntPtr的密码,UInt32的dwFlags中,布尔persistKeySet,SafeCertContextHandle和放大器; pCertCtx)
    在System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromBlob(字节[] RAWDATA,对象密码,X509KeyStorageFlags keyStorageFlags)
    在System.Security.Cryptography.X509Certificates.X509Certificate..ctor(字节[]数据)
    在System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(字节[] RAWDATA)
     

异常而执行:

  System.Security.Cryptography.CryptographicException,该系统找不到指定的文件。
 

解决方案

我建议先从这个博客帖子:的http://blog.tylerdoerksen.com/2013/08/23/pfx-certificate-files-and-windows-azure-websites/.虽然这个博客帖子是关于Azure的网站,而不是Azure的Webjobs本身不过我倾向于相信,你的问题是因为这个原因。事实上,我遇到了相同问题与Azure的网站。

不过,为了使用在博客中列出的解决方案,你不能使用 certstring 从发布设置文件原样。下面是你会什么需要做的:

  1. 在通过另一个控制台应用程序,首先要创建一个X509证书,并在本地计算机的证书存储区中安装。
  2. 导出PFX格式的证书,并提供一个密码。
  3. 在包含该PFX证书作为解决方案的一部分。如果Azure的网站的,我们必须包括的App_Data 文件夹这个文件,不知道在那里你将它列入情况Webjob的。你可以尝试这样,它是present在bin文件夹中。
  4. 读取该文件,并尝试使用(在这里和复制)在一篇博客文章中指定的语法创建X509证书的一个实例:

      VAR证书=新X509Certificate2(pfxFile,MYPASSWORD,X509KeyStorageFlags.MachineKeySet);
     

I built a Azure web job console which is referring Windows Azure Management Libraries. I tried to authenticate my app by using public setting approach.

The program is working fine on my local, but failing on Azure Web Jobs with X509Certificates error.

This is how I did for the web job program.

  1. Downloaded publish setting file from https://windows.azure.com/download/publishprofile.aspx

  2. On console app, create credential by copy & paste subscriptionId and cert string from the setting file.

    new CertificateCloudCredentials(
        subscriptionId,
        new  509Certificate2(Convert.FromBase64String(base64EncodedCertificate)));
    

  3. Deployed & tried "Run on Demand" on Azure Web Job.

  4. The error

    at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)
    at System.Security.Cryptography.X509Certificates.X509Utils._LoadCertFromBlob(Byte[] rawData, IntPtr password, UInt32 dwFlags, Boolean persistKeySet, SafeCertContextHandle& pCertCtx)
    at System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromBlob(Byte[] rawData, Object password, X509KeyStorageFlags keyStorageFlags)
    at System.Security.Cryptography.X509Certificates.X509Certificate..ctor(Byte[] data)
    at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(Byte[] rawData)
    

Exception while executing:

System.Security.Cryptography.CryptographicException, The system cannot find the file specified.

解决方案

I would suggest starting with this blog post: http://blog.tylerdoerksen.com/2013/08/23/pfx-certificate-files-and-windows-azure-websites/. Though this blog post is about Azure Websites and not Azure Webjobs per se however I'm inclined to believe that your problem is because of this. In fact, I ran into exact same problem with Azure Websites.

However in order to use the solution outlined in the blog post, you can't use the certstring from the publish setting file as is. Here's what you would need to do:

  1. Through another console application, first create an X509 certificate and install it in the certificate store of your local computer.
  2. Export the certificate in PFX format and provide a password.
  3. Include this PFX certificate as a part of your solution. In case of Azure Websites, we had to include this file in App_Data folder, not sure where you will include it in case of Webjob. You can try so that it is present in the bin folder.
  4. Read this file and try to create an instance of X509 Certificate using the syntax specified in the blog post (and copied here):

    var cert = new X509Certificate2(pfxFile, "myPassword", X509KeyStorageFlags.MachineKeySet);
    

这篇关于Windows Azure的管理库在网上工作认证错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆