login about faq


I've been stucked a while with this problem and i hope someone can help me. I need to sign and crypt a txt file for citibank but i can´t get it done, the requirements are:

The security requirements of CitiDirect Online Banking for the tool being utilized by the client for signing and encryption purposes are:

• Support for PKCS#7 Message standard (encryption and signing)

• Signing certificate must be included in the encoded message as per PKCS#7 standard.

• Signing format must be opaque (no clear-signing)

• Public Key trust chain must be included with encrypted/signed file

• Must utilize 3DES for symmetric encryption algorithm

• Must support SHA-1 RSA Public Key algorithms with key lengths of 1024 or larger

• You must upload your Public Key to CitiDirect prior to creating a File Delivery schedule.

• The tool must support the wrapping of a PKCS#7 structures in an ASN.1 Content Info structure

I´ve tried many ways to get this done, but i still don´t find a way out.

My code:

Private Function encryptandsign(ByVal strfile As String) As Boolean
        Dim sr As New StreamReader(strfile, System.Text.Encoding.UTF8)
        Dim strtocrypt As String = ""
        strtocrypt = sr.ReadToEnd()
        Dim mime As New Chilkat.Mime()
        Dim success As Boolean
        success = mime.UnlockComponent("30-day trial")
        If (success <> True) Then
            TextBox1.Text = TextBox1.Text & mime.LastErrorText & vbCrLf
            Exit Function
        End If

    '  Find our digital certificate from the Current User certificate store.
    Dim ccs As New Chilkat.CreateCS()
    Dim certStore As Chilkat.CertStore
    certStore = ccs.OpenCurrentUserStore()
    Dim cert As Chilkat.Cert
    cert = certStore.FindCertBySubjectCN("Juan Moreyra")

    If (cert Is Nothing) Then
        Exit Function
    End If

    '  Our MIME object is currently empty.  Add some header fields
    '  and a body:
    mime.AddHeaderField("Message-ID", "<CHILKAT-MID-83cf2fbf-10cb-4322-ad79-4c1097fd56f2@Matt>")
    mime.AddHeaderField("MIME-VERSION", "1.0")
    'mime.ContentType = "application/pkcs7-mime"
    mime.ContentType = "application/pkcs7-mime; smime-type=enveloped-data;"
    mime.Disposition = "attachment"
    mime.Filename = strfile
    'mime.Encoding = "base64"

    TextBox1.Text = TextBox1.Text & "Original MIME message:" & vbCrLf
    TextBox1.Text = TextBox1.Text & mime.GetMime() & vbCrLf
    mime.AddPfxSourceFile("kiddecer.pfx", "kidde")
    success = mime.ConvertToSigned(cert)
    If (success <> True) Then
        Exit Function
    End If

    Dim cert2 As New Chilkat.Cert
    success = cert2.LoadFromFile("C:\PROD_Encryption.cer")
    If (success <> True) Then
        'Text1.Text = Text1.Text & cert.LastErrorText & vbCrLf
        Call MsgBox(cert2.LastErrorText, MsgBoxStyle.Critical, "Error1")
        Exit Function
    End If
    mime.UseXPkcs7 = False
    mime.Pkcs7CryptAlg = "3des"
    mime.Pkcs7KeyLength = 192
    TextBox1.Text = TextBox1.Text & "----------------------------------" & vbCrLf
    TextBox1.Text = TextBox1.Text & "Signed Message:" & vbCrLf
    TextBox1.Text = TextBox1.Text & mime.GetMime() & vbCrLf

    mime.SaveMime(strfile + ".p7m")
End Function

The expected file should look like this:
Message-ID: 20631685.1349796827856.JavaMail.jg87553@LACMX31D1181661
Date: Tue, 9 Oct 2012 10:33:47 -0500 (CDT)
MIME-Version: 1.0
Content-Type: application/pkcs7-mime; smime-type=enveloped-data; 
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="C:/SMIMETool/Inbound/A092501.txt"


Help please!

asked Oct 24 '12 at 14:21

Daniel's gravatar image


edited Oct 24 '12 at 16:12

chilkat's gravatar image

chilkat ♦♦

Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Oct 24 '12 at 14:21

Seen: 2,331 times

Last updated: Apr 14 '13 at 22:27

powered by OSQA