RSA – Matching OpenSSL Signature w/ Chilkat

The following problem is common. The goal is to match the signature produced by this OpenSSL command w/ Chilkat:

cat in.txt | openssl dgst -sha1 -sign myPrivateKey.pem | openssl enc -base64

The “gotcha” is when the input text file ends with a linefeed character (a single byte having value 0x0A), but the programmer does not realize it. The bytes passed to the openssl dgst command must be exactly the same on both sides. Therefore, if the input file ends with a 0x0A (linefeed), then the bytes passed to the Chilkat RSA’s EncryptStringENC method must also include the linefeed. Be careful to match the line endings on both sides (Chilkat and OpenSSL) — i.e. don’t use CRLF on one side but a bare-LF on the other…

Tags :