Cannot sign message using USB TOKEN A3

0 votes
asked Apr 22 by David BS (120 points)

Hi,

I'm trying to sign a MailMessage using the following code:

    Dim Store As New Rebex.Security.Certificates.CertificateStore(CertificateStoreName.My)
    Dim options As CertificateFindOptions = CertificateFindOptions.HasPrivateKey Or CertificateFindOptions.IsTimeValid

    Dim Certificado() As Certificate = Store.FindCertificatesForMailAddress(RemetenteMailbox, options)

    If Certificado.Length > 0 Then
        Dim Signer As Certificate = Certificado(0)
        Dim parameters As New MailSignatureParameters()
        With parameters
                .Silent = False
        End With

    My_MIME_msg.Sign(parameters, Signer)

End If

The Certificate is correctly found in Store and I have my USB TOKEN attached.
When I call the SIGN function, the program raises the following error: UNABLE TO SIGN HASH

Interesting that the USB TOKEN is not called anyway.

I ran another program I made using BouncyCastle and Mimekit and everything goes ok: the TOKEN is called, it asks me the password, and so forth.

Do you know what am I doing wrong here?

I appreciate any help.

Applies to: Rebex Secure Mail

1 Answer

0 votes
answered Apr 26 by Lukas Matyska (47,230 points)

The problem was related to MS CryptoAPI.

We added workaround for "eToken Base Cryptographic Provider". The .NET PrivateKey is used instead of MS CryptoAPI.

This workaround will be included in release 2018 R2.

commented Apr 26 by David BS (120 points)
It's GREAT.
Thanks to all of you Team!
...