1

当我尝试调用使用 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 [

以下是堆栈跟踪的链接:

堆栈跟踪 - Pastebin

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

4

0 回答 0