locked
VB.net certchanin, signature meaning RRS feed

Answers

All replies

  • What did you do so far.

    Be aware that this is a part of the Windows Communication Foundation and you use it by doing

    Project -> Add service Reference

    http://msdn.microsoft.com/en-us/library/ms731082(v=vs.110).aspx


    Success
    Cor

    Monday, July 21, 2014 6:51 AM
  • What did you do so far.

    Be aware that this is a part of the Windows Communication Foundation and you use it by doing

    Project -> Add service Reference

    http://msdn.microsoft.com/en-us/library/ms731082(v=vs.110).aspx


    Success
    Cor

    Yes. I have added Service reference and done below coding. i have used code from this link to sign SOAP request. But i get error "'setpolicy' is not a member of 'ITRV1.ITRV1.TRVServicePortTypeClient'."

    Imports System
    Imports System.Security.Cryptography
    Imports System.Security.Cryptography.X509Certificates
    Imports System.Security.Cryptography.Xml
    Imports System.Text
    Imports System.Xml
    Imports System.IO
    
    Imports System.Collections.Generic
    Imports Microsoft.Web.Services3
    Imports Microsoft.Web.Services3.Design
    Imports Microsoft.Web.Services3.Security
    Imports Microsoft.Web.Services3.Security.Tokens
    Imports Microsoft.Web.Services3.Addressing
    Imports Microsoft.Web.Services3.Messaging
    
    
    Public Class Form1
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Try
    
                Dim DITWSAuthInfo1 As New ITRV1.DITWSAuthInfo
                Dim aa As New ITRV1.ITRVByAckNoRequest
                Dim sigEle As String = ""
                Dim certchain1 As String = ""
                DITWSAuthInfo1.userID = "*****"
                DITWSAuthInfo1.password = "*****"
                Dim sigEle2 As String = ""
                Dim certchain12 As String = ""
    
                DITWSAuthInfo1.signature = sigEle2
                DITWSAuthInfo1.certChain = certchain12
    
                aa.authInfo = DITWSAuthInfo1
                aa.acknowledgementNo = "123"
    
                Dim d1 As ITRV1.DITWSResponse
    
                Dim aaa As New ITRV1.TRVServicePortTypeClient
                aaa.setpolicy()
    
                d1 = aaa.getITRVByAckNo(aa)
                Stop
    
            Catch ex As Exception
                MsgBox(Err.Description & vbNewLine & ex.ToString)
            End Try
        End Sub
        Public Function FileBytes(ByVal FileName As String) As Byte()
            FileBytes = Nothing
            Try
    
                'Dim FBytes() As Byte
                'Dim FileHandle As Short
    
                'ReDim FBytes(FileLen(FileName) - 1)
    
                'FileHandle = FreeFile()
                'FileOpen(FileHandle, FileName, OpenMode.Binary, OpenAccess.Read)
                ''UPGRADE_WARNING: Get was upgraded to FileGet and has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
                'FileGet(FileHandle, FBytes)
                'FileClose(FileHandle)
    
                'Return FBytes  'shu 08.06.12'FileBytes = VB6.CopyArray(FBytes)
    
    
    
                Dim fs As New FileStream(FileName, FileMode.Open, FileAccess.Read)
                Dim ImageData(fs.Length) As Byte
    
    
                fs.Read(ImageData, 0, System.Convert.ToInt32(fs.Length))
    
                fs.Close()
                Return ImageData
    
    
    
            Catch ex As Exception
                FileBytes = Nothing
                MsgBox(ex.StackTrace & Err.Description)
            End Try
        End Function
        Function VerifyXmlFile(ByVal Name As String, Optional ByRef sigEle As String = "", Optional ByRef certchain1 As String = "") As [Boolean]
            Try
    
                ' Check the arguments.   
                If Name Is Nothing Then
                    Throw New ArgumentNullException("Name")
                End If
                ' Create a new XML document. 
                Dim xmlDocument As New XmlDocument()
    
                ' Format using white spaces.
                xmlDocument.PreserveWhitespace = True
    
                ' Load the passed XML file into the document. 
                xmlDocument.Load(Name)
    
                ' Create a new SignedXml object and pass it 
                ' the XML document class. 
                Dim signedXml As New SignedXml(xmlDocument)
    
                ' Find the "Signature" node and create a new 
                ' XmlNodeList object. 
                Dim nodeList As XmlNodeList = xmlDocument.GetElementsByTagName("Signature")
    
                ' Load the signature node.
                signedXml.LoadXml(CType(nodeList(0), XmlElement))
    
                If signedXml.CheckSignature = True Then
                    sigEle = nodeList(0).OuterXml
                    'Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" /><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" /><Reference URI=""><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" /></Transforms><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"
                    'sp cr dbt 'sigEle = nodeList(0).Item("SignatureValue").InnerText
                    'sigEle = "http://www.w3.org/TR/2001/REC-xml-c14n-20010315"
                    Try
                        Dim xmlele As XmlElement = signedXml.Signature.KeyInfo.GetXml
                        certchain1 = xmlele.GetElementsByTagName("X509Certificate").ItemOf(0).InnerText
                    Catch ex As Exception
    
                    End Try
                    Return True
                End If
                ' Check the signature and return the result. 
                Return signedXml.CheckSignature()
            Catch ex As Exception
                Return False
            End Try
    
        End Function
    
    
        
    End Class
    

    Monday, July 21, 2014 7:14 AM
  • I don't know if the first link will help or not. I believe the second link, for searching for answers about this kind of issue, could help you also.

    How to: Secure a Client Using a Policy File

    MSDN Library search engine

    Maybe this link too. Just found it.

    Implementing Message Layer Security with X.509 Certificates in WSE 3.0


    La vida loca


    Monday, July 21, 2014 7:58 AM
  • I assume that your question is for most of us to specialized. The problem is not VB but the signing.

    Therefore I suggest you to visit this WCF forum for your question.

    http://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=wcf


    Success
    Cor

    • Proposed as answer by Mr. Monkeyboy Monday, July 21, 2014 8:26 AM
    • Marked as answer by Just Karl Saturday, August 2, 2014 1:14 PM
    Monday, July 21, 2014 8:10 AM
  • I am trying to use web service "https://incometaxindiaefiling.gov.in/e-FilingWS/ditws/submitITR.wsdl" in our code.

    Documentation is available in https://incometaxindiaefiling.gov.in/eFiling/Portal/WebServices_Manual.pdf.

    3rd, 4th argument for this webservice are "Certification chain", "Signature". Something related to digital signatures I think.

    I am not able to get this. I am using vb.net. Regarding certchain got this link in C++.http://msdn.microsoft.com/en-us/library/windows/desktop/aa376078(v=vs.85).aspx

    What can be done? What should be those 3rd, 4th arguments?

    Hi,

    As Cor shared that WCF forum will be more dedicated for this issue, and I found that you have posted a thread in that forum, I would recommend you focus on that thread to get supports.

    http://social.msdn.microsoft.com/Forums/vstudio/en-US/9c827236-3492-4cd0-9685-a2fca917641f/what-are-certchanin-signature-in-soap-request-how-to-add?forum=wcf#48c4d20b-66af-4a69-bd1d-98b610ab05a8

    Thanks for your understanding.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, July 22, 2014 7:05 AM