Quantcast
Channel: Chilkat Forum - latest questions
Viewing all articles
Browse latest Browse all 1061

PKCS7 enveloping and sign a string

$
0
0

I have a code written in C# to sign and envelop a string to be sent to a web service, this code receives a certificate in the format ".pfx" and the certificate password

        string myString = "Hello World";
        X509Certificate2 cert = new X509Certificate2(@"<MY PFX FILE>", "<MY PASS>");
        CmsSigner signer = new CmsSigner(SubjectIdentifierType.IssuerAndSerialNumber, cert);
        signer.DigestAlgorithm = new Oid("<MY OID>");

        ContentInfo content = new ContentInfo(new Oid("<MY OID>"), new System.Text.UTF8Encoding().GetBytes(myString));
        SignedCms signedCms = new SignedCms(content, false);

        signedCms.ComputeSignature(signer, false);

        var asig = signedCms.Encode();

Now I need to write a code that does exactly the same thing, but in C, after performing several searches on google, I found this lib.

Knowing that I have to write a program that is cross-platform.

I found this example: https://www.example-code.com/C/rsa_sign_base64_pfx.asp

But in this example, the system create a rsa do encrypt the message...

But I did not find how I could sign and envelop the message, just like I am doing in C#, with OID... Thanks in advance if anyone can help me, how can I do the same thing I do in C# in C.


Viewing all articles
Browse latest Browse all 1061