使用SSL Web服务进行身份验证时出错

时间:2012-12-20 20:15:43

标签: vb.net ssl service web

当我尝试调用使用SSL身份验证的Web服务方法时,我收到以下错误,该证书已经安装在计算机上,我可以在Google Chrome中成功打开Web服务。我过去两天都被困住了,我不知道还能做什么。

Function Deceval(ByVal xmlstr As String, ByVal certname As String, ByRef error_cert As Boolean, ByRef user As String, ByRef password As String, ByRef vectrama As String(), ByRef url As String, ByVal vecrutas As String(), ByVal cert As X509Certificate2)
    Try
        Dim WSCompany As SDLService = New SDLService()
        Dim petitionWS As RequestCreateReceiptServiceDTO = New RequestCreateReceiptServiceDTO()
        Dim answerFromWS As ResponseReceiptServiceDTO
        Dim signatureToken As X509SecurityToken = New X509SecurityToken(cert)
        Dim userNameToke As New UsernameToken(user, password)
        Dim x509str As X509SecurityToken = New X509SecurityToken(signatureToken.Certificate)
        Dim sig As New MessageSignature(x509str)

        WSCompany.RequestSoapContext.Security.Tokens.Add(userNameToke)
        WSCompany.RequestSoapContext.Security.Elements.Add(sig)
        WSCompany.RequestSoapContext.Security.Tokens.Add(x509str)
        WSCompany.RequestSoapContext.Security.Timestamp.TtlInSeconds = 60


        Dim soapHeader As HeaderDTO = New HeaderDTO()
        petitionWS.Header = soapHeader
        'This date was hardcoded because I thought the error was caused
        'by a time zone difference (it is not apparently)
        petitionWS.Header.Date = "2012-12-20T17:21:30Z"
        petitionWS.Header.Hour = "17:21PM"
        petitionWS.Header.User = "oraclell"
        petitionWS.Header.DepositCode = "110011"

        ServicePointManager.ServerCertificateValidationCallback = Function(obj As [Object], certificate As X509Certificate, chain As X509Chain, errors As SslPolicyErrors)
                                                                      Return True
                                                                  End Function

        WSCompany.ClientCertificates.Add(signatureToken.Certificate)
        WSCompany.Url = serviceURL
        'Calling the createReceipt() web service method. The error shows up when stepping in the line below :(
        answerFromWS = WSCompany.createReceipt(petitionWS)

        Return ""
    Catch ex As Exception
        error_cert = True
        register.log("Error consuming web service -- " & ex.ToString, "Log_ConsWS.txt", webFilePaths)
        Return xmlstr
    End Try
End Function

这会导致以下错误:

Security token failed to validate. weblogic.xml.crypto.wss.SecurityTokenValidateResult@4c104c10[status: false][msg [

以下是堆栈跟踪的链接:

Stack trace - Pastebin

任何帮助或线索将不胜感激。

0 个答案:

没有答案