IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only

Detached signature for WebMethods using .Net framework

  • 1.  Detached signature for WebMethods using .Net framework

    Posted Sat August 30, 2008 09:08 PM

    Hello experts

    Hello
    I wrote the below functions to generate a detached signature that will be decrypted using webMethods:

    webMethods generates the following error when trying to decrypt the signature signed using this VB.NET function

    Certificate Verification Failed. Invalid Serial Number

    Here is the VB.NET code:

    
    Function SignString(ByVal strTosign As String) As String
    Dim docStrToSign As New XmlDocument
    docStrToSign.LoadXml(strTosign)
    docStrToSign.PreserveWhitespace = False
    Dim stringToSign As String = docStrToSign.OuterXml
    Dim utf8encoder As UTF8Encoding = New UTF8Encoding()
    Dim inputInBytes() As Byte = utf8encoder.GetBytes(stringToSign)
    Dim sigBytes() As Byte = ComputeSignature(inputInBytes)
    Return Convert.ToBase64String(sigBytes)
    End Function
    Function ComputeSignature(ByVal inputInBytes() As Byte) As Byte()
    Dim x509Cert As New X509Certificate2(System.Configuration.ConfigurationManager.AppSettings.Item("PrivateKeyPath") _
    & System.Configuration.ConfigurationManager.AppSettings.Item("PrivateKeyFile"), _
    System.Configuration.ConfigurationManager.AppSettings.Item("PrivateKeyPassword"))
    Dim ci As New ContentInfo(New Oid("1.3.14.3.2.26"), inputInBytes)
    Dim signed As New SignedCms(ci, True)
    Dim cs As New CmsSigner(x509Cert)
    cs.IncludeOption = X509IncludeOption.WholeChain
    signed.ComputeSignature(cs)
    Return signed.Encode()
    End Function

    Is there any compatibility issue between webMethods cryptography and .Net framework cryptography?
    The above code demonstrates the procedure proposed by our partner for signing XML messages using .Net framework.


    #Integration-Server-and-ESB
    #B2B-Integration
    #webMethods