Vb.net 使用客户端证书错误调用SOAP web服务-从服务器接收到的身份验证标头为'';
我试图使用客户机证书调用SOAP web服务,并收到以下错误消息 HTTP请求未经客户端身份验证方案“匿名”授权。从服务器收到的身份验证标头为“”。 在需要保护web服务之前,我能够使用下面的代码减去证书代码来检索数据。我已验证证书代码是否正确地从我的证书存储中检索客户端证书信息。在代码下面,我还添加了我的应用程序配置信息 有谁能告诉我为什么会收到上述错误消息?提前感谢任何能够提供任何见解的人Vb.net 使用客户端证书错误调用SOAP web服务-从服务器接收到的身份验证标头为'';,vb.net,web-services,ssl,soap,x509certificate2,Vb.net,Web Services,Ssl,Soap,X509certificate2,我试图使用客户机证书调用SOAP web服务,并收到以下错误消息 HTTP请求未经客户端身份验证方案“匿名”授权。从服务器收到的身份验证标头为“”。 在需要保护web服务之前,我能够使用下面的代码减去证书代码来检索数据。我已验证证书代码是否正确地从我的证书存储中检索客户端证书信息。在代码下面,我还添加了我的应用程序配置信息 有谁能告诉我为什么会收到上述错误消息?提前感谢任何能够提供任何见解的人 Friend Function GetWorkByBAWTS(ByVal sBAWTSLook
Friend Function GetWorkByBAWTS(ByVal sBAWTSLookupName As String, ByVal sUnit As String, ByVal sWorkType As String, ByVal sStatus As String) As ArrayList
System.Net.ServicePointManager.Expect100Continue = False
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls Or SecurityProtocolType.Ssl3 Or SecurityProtocolType.Tls11 Or SecurityProtocolType.Tls12
Dim sSearchType As X509FindType = DirectCast([Enum].Parse(GetType(X509FindType), ConfigurationManager.AppSettings("searchtype")), X509FindType)
Dim sSubjectValue As String = ConfigurationManager.AppSettings("searchvalue")
Dim sDelimiter As String = ConfigurationManager.AppSettings("delimiter")
Dim sStoreName As StoreName = DirectCast([Enum].Parse(GetType(StoreName), ConfigurationManager.AppSettings("storename")), StoreName)
Dim sStoreLocation As StoreLocation = DirectCast([Enum].Parse(GetType(StoreLocation), ConfigurationManager.AppSettings("storelocation")), StoreLocation)
Dim cert As X509Certificate2 = Nothing
Dim store As X509Store = New X509Store(StoreName.My, StoreLocation.CurrentUser)
store.Open(OpenFlags.ReadOnly Or OpenFlags.OpenExistingOnly)
Dim certcollection As X509Certificate2Collection = store.Certificates.Find(sSearchType, sSubjectValue, False)
Dim activecollection As X509Certificate2Collection = certcollection.Find(X509FindType.FindByTimeValid, DateTime.Now, False)
cert = certcollection(0)
store.Close()
Dim iRetry As Integer = 0
Dim alWorkItems As New ArrayList
Dim oResponse As lookupObjectsResponse = Nothing
Dim oClient As ProcessingServiceClient = New ProcessingServiceClient("ProcessingServicePort")
oClient.ClientCredentials.ClientCertificate.Certificate = cert
oClient.Endpoint.Address = New ServiceModel.EndpointAddress("https://mywebservice:8443/prodapp/ProcessingService?wsdl")
Dim oRequest As lookupObjects = New lookupObjects()
oRequest.lookupObjectsRequest = New lookupObjectsRequest()
oRequest.lookupObjectsRequest.lookupName = "LKWTSTAT"
oRequest.lookupObjectsRequest.lookupParameters = New lookupObjectsRequestLookupParameters()
m_oAuthInfo = New authorizationInfo()
m_oAuthInfo.userId = "user1"
oClient.ClientCredentials.UserName.UserName = "user1"
oClient.ClientCredentials.UserName.Password = "password"
Dim oItems As lookupParameter()
ReDim oItems(2)
oRequest.lookupObjectsRequest.lookupParameters.Items = oItems
oRequest.lookupObjectsRequest.lookupParameters.Items(0) = New lookupParameter()
oRequest.lookupObjectsRequest.lookupParameters.Items(0).name = "businessArea"
oRequest.lookupObjectsRequest.lookupParameters.Items(0).Value = sUnit
oRequest.lookupObjectsRequest.lookupParameters.Items(1) = New lookupParameter()
oRequest.lookupObjectsRequest.lookupParameters.Items(1).name = "type"
oRequest.lookupObjectsRequest.lookupParameters.Items(1).Value = sWorkType
oRequest.lookupObjectsRequest.lookupParameters.Items(2) = New lookupParameter()
oRequest.lookupObjectsRequest.lookupParameters.Items(2).name = "status"
oRequest.lookupObjectsRequest.lookupParameters.Items(2).Value = sStatus
oResponse = oClient.lookupObjects(m_oAuthInfo, oRequest)
If Not oResponse.lookupObjectsResponse1.Items Is Nothing Then
For Each oWorkItem As workInstance In oResponse.lookupObjectsResponse1.Items
alWorkItems.Add(oWorkItem)
Next
End If
Return alWorkItems
End Function
app.config
<configuration>
<configSections>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="AWDProcessingServiceBinding" closeTimeout="00:01:00"
openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="655360" maxBufferPoolSize="524288" maxReceivedMessageSize="655360"
messageEncoding="Mtom" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<!-- <security mode="Transport">
<transport clientCredentialType="Certificate" proxyCredentialType="Basic" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security> -->
<security mode="Transport">
<transport clientCredentialType="Certificate" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://mywebservice:8443/betaapp/ProcessingService?wsdl"
binding="basicHttpBinding" bindingConfiguration="ProcessingServiceBinding"
contract="PS.ProcessingService" name="AWDProcessingServicePort" />
</client>
</system.serviceModel>
<appSettings>
*** removed cert info ***
</appSettings>
***删除证书信息***
更新:问题是传入的用户Id被禁用。id已重新启用,这更正了我的问题。如果启用了
匿名身份验证
,请检查IIS中的身份验证
方法。很抱歉,为澄清此web服务由第三方托管,而不是在IIS上。我会让他们检查他们的设置,无论是什么网络服务器正在使用。但是,我实际上是在将客户机证书信息传递给web服务,那么为什么会出现客户机身份验证是匿名的错误呢?此外,通过浏览器手动访问wsdl,确实需要选择证书。