【问题标题】:Web application working on iis7 but not on local machineWeb 应用程序在 iis7 上工作,但不在本地机器上
【发布时间】:2015-03-23 16:09:29
【问题描述】:

我在 ISS7 服务器上成功构建和编译了我的 VB.NET Web 应用程序,但在通过 Visual studion 2013 编译时在本地计算机上它是 返回“System.Security.Cryptography.CryptographicException:系统找不到指定的文件。”错误。 不确定发生了什么,但在Dim cert As New X509Certificate2(certFile, certFilePassword,X509KeyStorageFlags.MachineKeySet) 处抛出错误

下面是我尝试使用安装在本地计算机上的证书的代码。

Sub LoginED(ByVal token As String)
Try
'We need the ED user ID
lblEDUserID.Text = GetEDUserID().ToString()

'Track user login
InsertLogin(txtEDUsername.Text, True)

'Set login cookies for ED users            
If lblEDUserID.Text = "0" Then
lblEDLoginStatus.Text = "You have entered an incorrect login. Please try again."
Else

Dim certFile As String = "VIP_Cert.pfx"
Dim certFilePassword As String = "password"

Dim cert As New X509Certificate2(certFile, certFilePassword,X509KeyStorageFlags.MachineKeySet)
Dim vipSoapInterfaceQueryServiceCert As New WebReference.QueryService

'Dim fs As FileStream = File.Open(certFile, FileMode.Open, FileAccess.ReadWrite)
'Dim filesize As Long = fs.Length
'Dim buffer(filesize) As Byte
'fs.Read(buffer, 0, filesize)

'byte[] buffer = new byte[fs.Length];
'int count = fs.Read(buffer, 0, buffer.Length);
'fs.Close()

lblEDLoginStatus.Text = "Activation  "
vipSoapInterfaceQueryServiceCert.ClientCertificates.Add(cert)

Dim vipSoapInterfaceService As New WebReference.GetCredentialInfoRequestType()
vipSoapInterfaceService.credentialId = "SMR23324543"
vipSoapInterfaceService.credentialType = WebReference.CredentialTypeEnum.STANDARD_OTP
vipSoapInterfaceService.requestId = "ABCD"

Dim vipSoapInterfaceResponse As New WebReference.GetCredentialInfoResponseType()

vipSoapInterfaceResponse = vipSoapInterfaceQueryServiceCert.getCredentialInfo(vipSoapInterfaceService)
lblEDLoginStatus.Text = "WebService Response: " + vipSoapInterfaceResponse.credentialId + ", Status:" + vipSoapInterfaceResponse.credentialStatus

End If
Finally

到目前为止我已经尝试过: 1) 尝试指定证书文件在机器上的完整路径。

2) 尝试了不同格式的证书(.pfx;.p12;.cer)

3) 尝试打开、读取证书并将其发送到缓冲区以从缓冲区获取输入。 (我在IIS7上部署时去掉了缓冲逻辑,因为我将.pfx证书文件放在System32文件夹中,代码可以自动识别证书,但本地不识别)

4) 我尝试删除“X509KeyStorageFlags.MachineKeySet”参数。 (我用它来编译 IIS7)

感谢任何帮助!

【问题讨论】:

  • 我建议检查本地计算机上的应用程序池与引发异常的服务器之间的差异。闻起来像是权限问题...

标签: vb.net web-services ssl-certificate client-certificates


【解决方案1】:

谢谢!我可以弄清楚需要什么。 我必须为证书创建一个应用程序池,然后为该池提供完全控制权限

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-11
    • 1970-01-01
    • 2014-01-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多