Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Add Digital Signature Using C# and Acrobat SDK

New Here ,
Feb 21, 2008 Feb 21, 2008
Hi everybody!

Please, how can I digitally sign PDF documents using Acrobat Professional 8 API and C# language?
I know that I need use JavaScript APIs (IAC) but I can't find anything really helpful in the Acrobat SDK Documentation. Could anyone post a sample of how use javascript manipulation inside C# (Framework 2.0), or give me a direction?

Thank in advance!
TOPICS
Acrobat SDK and JavaScript
46.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 15, 2008 Mar 15, 2008
If it's compatible with Acrobat, you'll need to research the crypto provider functions (they are all thoroughly documented in the JS API Reference). You are already using one of these methods in your current code, it is just referencing the default Adobe crypto provider.

If your hardware is not compatible with Acrobat (i.e. you can't manually use it within the Acrobat UI) then you will need to use it's own APIs, which has nothing to do with the Acrobat SDK and we would not be able to help you here.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 25, 2008 Mar 25, 2008
PDL, I searched a lot in the internet and in the Acrobat Documentation to how use the acrobat sdk and javascript to sign a document using a certificate stored in a smartcard.
When I use a smart card (PKCS#11 Device) inside the Acrobat, it recognises the smart card and I can sign de document using the card (no PFX certificates are needed).
When I plug the card in my pc, appears in the "Windows Certificate Store" the certificate that are stored in the card. So, using Javascript I found the serial number of the certicate stored in the smart card (I'm sure that the serial number is correct), and I tried to use it and Javascript to sign a pdf document, like below:

var myEngine = security.getHandler("Adobe.PPKLite");
var oCerts = myEngine.digitalIDs.certs;
var serial = "XXXXXX"; //serial number of the certificat that I am looking for in the "Windows Cert Store"
var iSerial;

//search in the windows store certificate for a certificate with the serial number informed
for (var i=0; i < oCerts.length; i++)
{
if (oCerts.serialNumber == serial)
i = iSerial;
}

console.println("Signing using the certificate: "+oCerts[iSerial]);

myEngine.login( {oParams:{oEndUserSignCert: oCerts[iSerial] , cPassword: "MyPassword"}});
var f = this.getField("SignHere");

f.signatureSign( myEngine,
{password: "MyPassword",// provide password
location: "Local",
reason: "Any reason",
contactInfo: "555-5555",
appearance: "MyApperance"});

The code above can't loggin the certificate, the problem is that the password is ignored by the code, and I don't know why.
I did a test, if I pass a path of any other PFX certificate in my pc instead of the object certificate (oCerts[iSerial]) the code above works fine: read the password and can loggin the certificate.

Any idea, please??

Thanks all in advance!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 25, 2008 Mar 25, 2008
PKCS#11 (Cryptoki API) is just an abstract set of generic functions for (mostly) smart card certificates. In what format are your certificates on the smart card?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 25, 2008 Mar 25, 2008
Hi PDL, thank you again.
I can't access the smart card directly, but, reading the documentation of the smart card, the format of the certificate is
PFX.
Any idea?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 25, 2008 Mar 25, 2008
PFX is usually PKCS#12. Strange, you should have the added password field (that field is only processed in a SignatureInfo variable on public-key certificates). Perhaps since it's coming from MSCAPI it is not seeing it as a public-key certificate.

If you just console.println(oCerts[iSerial]) what does it output?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 25, 2008 Mar 25, 2008
[object Certificate = SubjectDN: cn=Felipe Fornachari, email=MyEmail, o=MyCompany, ou=MycompanyUnit, c=MyCountry]

I just change my personal informations, but the output is like above.
This is the right output, is'nt it?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 25, 2008 Mar 25, 2008
I just noticed something. When you're performing your login you are using an optional LoginParameters object.

myEngine.login( {oParams:{oEndUserSignCert: oCerts[iSerial] , cPassword: "MyPassword"}});

You are not specifying the cDIPath parameter which must point to your smart cards PKCS#11 library.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 25, 2008 Mar 25, 2008
Thank you PDL, but It isn't the problem.
I tried now this:

myEngine.login( {oParams:{cPassword: "MyPassword", cDIPath: oCerts[iSerial]}});

But did not work. But, if I pass a valid PFX path instead of oCerts[iSerial], this code works, like the other.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 25, 2008 Mar 25, 2008
Yes, that is because your certificate is not a PKCS#11 Library. That is stored on the smart card. You may have to discuss with the manufacturer how to access it.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 25, 2008 Mar 25, 2008
Ok, thank you!
I will search a little more.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 16, 2010 Feb 16, 2010
LATEST

Fornachari,

I am looking for a solution for a very similar problem - Signing a PDF with C# and Acrobat SDK using certificate stored in a USB Token.

Did you find a solution for this? Any help is really appreciated.

Thanks,

Paddy

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 19, 2008 Jun 19, 2008
Hi PDL/Fornachari,

I am using VB.Net and i have to create .PostScript file using Adobe javascript.

I am able to create .ps in abode using javascript.

Now I want to call that Javascript in my VB.Net code using JSO object.

I copied the javascript in C:\Program Files\Adobe\Acrobat 8.0\Acrobat\Javascripts folder.

VB.NET Code:-

Dim gApp As Acrobat.CAcroApp
Dim gPDDoc As Acrobat.CAcroPDDoc
Dim jso As Object

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

gApp = CreateObject("AcroExch.App")
gPDDoc = CreateObject("AcroExch.PDDoc")
jso = gPDDoc.GetJSObject

End Sub

Adobe Javasccript:-

function JSPDFTOPS(theDoc)
{
var pp = theDoc.getPrintParams();
pp.interactive = pp.constants.interactionLevel.silent;
var fv = pp.constants.flagValues;
pp.flags |= fv.setPageSize;
theDoc.print(pp);
}

Now please guide how can i call this javascript into my VB.Net code.

Thanks in Advance
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 19, 2008 Jun 19, 2008
>I am using VB.Net and i have to create .PostScript file using Adobe javascript.

Are you trying to add a digital signature? Are you using C#?
If not, I recommend you start a new topic, because adding to an
unrelated topic will be less helpful to you.

Good luck,

Aandi Inston
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 19, 2008 Jun 19, 2008
Hi Aandi Inston,

I posted a new topic.

Thanks a lot for your response.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines