Menu

#1 error in application

closed-works-for-me
5
2014-08-25
2010-01-18
Anonymous
No

I am trying to do simple windows signing of pdf but this is the error i get:

C:\Program Files\JSignPdf>java -jar JSignPdf.jar -kst WINDOWS-MY barkod_proba.pd
f
Getting keystore type instance: WINDOWS-MY
Getting key alias
Loading private key
Getting certificate chain
Opening input PDF file: barkod_proba.pdf
Creating output PDF file: ./barkod_proba_signed.pdf
Creating signature
Setting certification level
Processing (it may take a while) ...
Problem occured
java.lang.NullPointerException
at com.lowagie.text.pdf.PdfPKCS7.<init>(Unknown Source)
at com.lowagie.text.pdf.PdfSigGenericPKCS.setSignInfo(Unknown Source)
at com.lowagie.text.pdf.PdfSignatureAppearance.preClose(Unknown Source)
at com.lowagie.text.pdf.PdfSignatureAppearance.preClose(Unknown Source)
at com.lowagie.text.pdf.PdfStamper.close(Unknown Source)
at net.sf.jsignpdf.SignerLogic.run(SignerLogic.java:168)
at net.sf.jsignpdf.Signer.signFiles(Signer.java:120)
at net.sf.jsignpdf.Signer.main(Signer.java:68)
Finished: Creating of signature failed.

I generated certificate from windows CA which i installed locally and tried to run sign application.

Any clues what could be the problem?

Discussion

  • Anonymous

    Anonymous - 2010-01-19

    Still problem but with different message

    When i used windows-my option:

    Starting PDF Signer
    Getting key alias
    Used key alias: {0}
    Loading private key
    Getting certificate chain
    Opening input PDF file: C:\Documents and Settings\dreic\My Documents\barkod_proba.pdf
    Creating output PDF file: C:\Documents and Settings\dreic\My Documents\barkod_proba_sign.pdf
    Creating signature
    Setting reason: test
    Setting location: Split, ITsistemi
    Setting certification level
    Processing (it may take a while) ...
    Problem occured
    java.lang.NullPointerException
    at com.lowagie.text.pdf.PdfPKCS7.<init>(Unknown Source)
    at net.sf.jsignpdf.SignerLogic.run(SignerLogic.java:175)
    at java.lang.Thread.run(Unknown Source)
    Finished: Creating of signature failed.

    This is with JKS keystore:

    Starting PDF Signer
    Getting key alias
    Used key alias: {0}
    Loading private key
    Problem occured
    java.lang.NullPointerException
    at sun.security.provider.JavaKeyStore$JKS.convertAlias(Unknown Source)
    at sun.security.provider.JavaKeyStore.engineGetKey(Unknown Source)
    at sun.security.provider.JavaKeyStore$JKS.engineGetKey(Unknown Source)
    at java.security.KeyStore.getKey(Unknown Source)
    at net.sf.jsignpdf.KeyStoreUtils.getPkInfo(KeyStoreUtils.java:236)
    at net.sf.jsignpdf.SignerLogic.run(SignerLogic.java:60)
    at java.lang.Thread.run(Unknown Source)
    Finished: Creating of signature failed.

    I think the button Load keys isn't working. If i select JKS and press load keys i don't see anything and there should be my allias since i created java keystore with allias when i was importing certificate.

     
  • Josef Cacek

    Josef Cacek - 2010-01-19

    OK, it seems, you have no "Private key" in your keystore (or Java couldn't for some reason read it). Isn't it possible, you have only certificates without private key in the keystore?
    Do you see your certificates in "Internet Options->Content->Certificates->Personal"?

    The normal output should look like (see the value "Used key alias"):

    c:\Program Files\JSignPdf>java -Duser.language=en -jar JSignPdf.jar -kst WINDOWS-MY docs/JSignPdf.pdf
    Getting key alias
    Used key alias: signKey#1
    Loading private key
    Getting certificate chain
    Opening input PDF file: docs/JSignPdf.pdf
    Creating output PDF file: ./JSignPdf_signed.pdf
    Creating signature
    Setting certification level
    Processing (it may take a while) ...
    Closing result PDF stream
    Finished: Signature succesfully created.

     
  • Josef Cacek

    Josef Cacek - 2010-01-19
    • status: open --> open-works-for-me
     
  • Anonymous

    Anonymous - 2010-01-19

    I have 2 personal certificate with private key which is stored on USB smart card. C So in order to sign documents (doc, emai, pfd) with thosw 2 certificates i get a popup windows which requries me to enter PIN to be able to sign document (in Word, Outlook or Adobe Acrobat).

    The key i generated from my domain CA doesn't have private key.

     
  • Josef Cacek

    Josef Cacek - 2010-01-19

    And do you see your key aliases in the JSignPdf GUI?

     
  • Josef Cacek

    Josef Cacek - 2010-01-20

    Then I suppose the problem comes from Java-Windows communication and the JSignPdf is only a victim of this bug/behavior/...

     
  • Nobody/Anonymous

    You were right. I installed everything od Windows 2003 (was XP previous) and it worked.

    Btw i am interested are you considering in implementing batch signing ? For example "sign all(*) .pdf files in C:\xx directory and add _signed to name of the file in destination folder".

     
  • Josef Cacek

    Josef Cacek - 2010-01-20
    • status: open-works-for-me --> closed-works-for-me
     
  • Josef Cacek

    Josef Cacek - 2010-01-20

    Batch signing should be enough powerfull already. Please consult possibilities of your shell (cmd /?, set /?, ...)
    You can try e.g. following batch (run in "cmd /V:ON"):

    set FILES=
    for %%i in (c:\YourPath\*.pdf) do set FILES=!FILES! "%%i"
    java -jar JSignPdf.jar -kst WINDOWS-MY %FILES%

    Yes, with Linux is live easier :-)

     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.