login about faq

I have this code that signs a file and then outputs a detached signature file. The code works perfectly on one machine, but I go to a newer machine and it does not work. I have tried all versions of chilkat and it won't generate the signature file, but the code compiles and has no issues. I copied the code below. Please HELP!

//in Nuget ChilkatDotNet4 void Main() { Chilkat.Crypt crypt = new Chilkat.Crypt();


// Read the PDF
System.IO.FileInfo fInfo = new System.IO.FileInfo(@"D:\AttidoMobile\manifest.json");
System.IO.BinaryReader br = new System.IO.BinaryReader(
byte [] pdfBytes = br.ReadBytes((int)fInfo.Length);

// Indicate which digital certificate is to be used.
// This certificate must have the private key installed on the system.
Chilkat.Cert cert = new Chilkat.Cert();
// Replace this line with your own .cer or .p7b file.

// Create the signature.
byte [] signature = crypt.CreateSignature(pdfBytes);

// Save the signature to a file.
System.IO.BinaryWriter bw = new System.IO.BinaryWriter(

// Now load the signature back into another byte array.
fInfo = new System.IO.FileInfo(@"D:\AttidoMobile\signature");
br = new System.IO.BinaryReader(
byte [] sigBytes = br.ReadBytes((int)fInfo.Length);

// This should be valid.
bool valid1 = crypt.VerifySignature(pdfBytes,sigBytes);

// Modify the data, and verify should return false.
pdfBytes[0] = 0xCC;
bool valid2 = crypt.VerifySignature(pdfBytes,sigBytes);

Console.WriteLine("valid1 = " + valid1 + ", valid2 = " + valid2);


// Define other methods and classes here

asked Mar 03 '16 at 23:15

mathis1337's gravatar image


edited Mar 03 '16 at 23:16

The LastErrorText property is the place to get information about what transpired in any given Chilkat method call. Turn on the VerboseLogging property to get more verbose information in LastErrorText.

When faced with a problem, the 1st step in solving it is to ask the question: Where and how can I get information about what happened? The answer to that question w/Chilkat is always the LastErrorText property. (There may be other properties that can help -- make sure to review the reference documentation -- there may be a SessionLog property, or a "fail reason" property, etc.)


answered Mar 04 '16 at 10:48

chilkat's gravatar image

chilkat ♦♦

Well whats weird is the code works on my work machine, but I then take home to my personal machine and it fails... has that happened before? I assume I am missing some download or file, i Have tried all the c++ runtime stuff, and the active x things. anything else I might be missing? I am using Chilkatdotnet4, is that lasterrortext in that? Thank you for replying also!

(Mar 04 '16 at 10:53) mathis1337

Ok, so I figured it out... Apparently the certificate also has to be in the certificate store. you just can't load the .cer file. I did all that and now its working on my new machine. The Last.ErrorText is what helped me though, so thanks for the tip!!!!


answered Mar 04 '16 at 10:53

mathis1337's gravatar image


edited Mar 04 '16 at 11:32

Your answer
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: Mar 03 '16 at 23:15

Seen: 1,028 times

Last updated: Mar 04 '16 at 11:32

powered by OSQA