pdf signature problem on adobe reader 9

View: New views
5 Messages — Rating Filter:   Alert me  

pdf signature problem on adobe reader 9

by halil :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Hi,
I sign a pdf using the code below and then when I want to open it in adobe reader 8 or previous versions it works fine and I can see the signature but when I open it with adobe reader 9.0 I couldnt see the signature what can be the problem ? can anyone help me?

                byte[] pdfBits = baos.toByteArray();
                SunPKCS11 akisProvider = new SunPKCS11(Configuration.getHSMSettings());
                Security.addProvider(akisProvider);
                KeyStore ks = KeyStore.getInstance("PKCS11", akisProvider);
                ks.load(null, hsmPassword);
                String alias = ks.aliases().nextElement();
                key = (PrivateKey) ks.getKey(alias, hsmPassword);
                chain = new java.security.cert.Certificate[1];
                chain[0] = ks.getCertificate(alias);

            reader = new PdfReader(new ByteArrayInputStream(pdfBits));

            ByteArrayOutputStream fout = new ByteArrayOutputStream();

            PdfStamper stp = PdfStamper.createSignature(reader, fout, '\0');
         
            PdfSignatureAppearance sap = stp.getSignatureAppearance();

            sap.setCertificationLevel(PdfSignatureAppearance.CERTIFIED_NO_CHANGES_ALLOWED);

            sap.setRender(PdfSignatureAppearance.SignatureRenderNameAndDescription);
            sap.setCrypto(key, chain, null,PdfSignatureAppearance.WINCER_SIGNED);
            sap.setReason("Bu belgenin içeriği doğrudur ve tamdır.");
            sap.setLocation("Ankara, TR");

            Rectangle size = reader.getPageSize(1);
            size.setLeft(size.getRight() - 220);
            size.setRight(size.getRight() - 20);
            size.setBottom(size.getTop() - 70);
            size.setTop(size.getTop() - 20);
            sap.setVisibleSignature(size, 1, null);
            stp.close();
           
            try {
                FileOutputStream fos;
                fos = new FileOutputStream(new File("C:/imzali_dfg.pdf"));
                fos.write(fout.toByteArray() );
                fos.flush();
                fos.close();
            } catch ( Exception e) {
                e.printStackTrace();
            } 

      Halil


Access your email online and on the go with Windows Live Hotmail. Sign up today.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
iText-questions mailing list
iText-questions@...
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php

Re: pdf signature problem on adobe reader 9

by Leonard Rosenthol :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Please provide a sample PDF that demonstrates the problem.

Leonard

On Dec 1, 2008, at 2:16 PM, mustafahalil yildiz wrote:


Hi,
I sign a pdf using the code below and then when I want to open it in adobe reader 8 or previous versions it works fine and I can see the signature but when I open it with adobe reader 9.0 I couldnt see the signature what can be the problem ? can anyone help me?

                byte[] pdfBits = baos.toByteArray();
                SunPKCS11 akisProvider = new SunPKCS11(Configuration.getHSMSettings());
                Security.addProvider(akisProvider);
                KeyStore ks = KeyStore.getInstance("PKCS11", akisProvider);
                ks.load(null, hsmPassword);
                String alias = ks.aliases().nextElement();
                key = (PrivateKey) ks.getKey(alias, hsmPassword);
                chain = new java.security.cert.Certificate[1];
                chain[0] = ks.getCertificate(alias);

            reader = new PdfReader(new ByteArrayInputStream(pdfBits));

            ByteArrayOutputStream fout = new ByteArrayOutputStream();

            PdfStamper stp = PdfStamper.createSignature(reader, fout, '\0'); 
          
            PdfSignatureAppearance sap = stp.getSignatureAppearance();

            sap.setCertificationLevel(PdfSignatureAppearance.CERTIFIED_NO_CHANGES_ALLOWED);

            sap.setRender(PdfSignatureAppearance.SignatureRenderNameAndDescription);
            sap.setCrypto(key, chain, null,PdfSignatureAppearance.WINCER_SIGNED);
            sap.setReason("Bu belgenin içeriği doğrudur ve tamdır.");
            sap.setLocation("Ankara, TR");

            Rectangle size = reader.getPageSize(1);
            size.setLeft(size.getRight() - 220);
            size.setRight(size.getRight() - 20);
            size.setBottom(size.getTop() - 70);
            size.setTop(size.getTop() - 20);
            sap.setVisibleSignature(size, 1, null);
            stp.close(); 
            
            try {
                FileOutputStream fos; 
                fos = new FileOutputStream(new File("C:/imzali_dfg.pdf")); 
                fos.write(fout.toByteArray() );
                fos.flush();
                fos.close();
            } catch ( Exception e) { 
                e.printStackTrace();
            }  

      Halil


Access your email online and on the go with Windows Live Hotmail. Sign up today. -------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/_______________________________________________
iText-questions mailing list
iText-questions@...
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
iText-questions mailing list
iText-questions@...
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php

Re: pdf signature problem on adobe reader 9

by halil :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
sample is at attached..

halil




From: leonardr@...
To: itext-questions@...
Date: Mon, 1 Dec 2008 20:35:54 +0100
Subject: Re: [iText-questions] pdf signature problem on adobe reader 9

Please provide a sample PDF that demonstrates the problem.

Leonard

On Dec 1, 2008, at 2:16 PM, mustafahalil yildiz wrote:


Hi,
I sign a pdf using the code below and then when I want to open it in adobe reader 8 or previous versions it works fine and I can see the signature but when I open it with adobe reader 9.0 I couldnt see the signature what can be the problem ? can anyone help me?

                byte[] pdfBits = baos.toByteArray();
                SunPKCS11 akisProvider = new SunPKCS11(Configuration.getHSMSettings());
                Security.addProvider(akisProvider);
                KeyStore ks = KeyStore.getInstance("PKCS11", akisProvider);
                ks.load(null, hsmPassword);
                String alias = ks.aliases().nextElement();
                key = (PrivateKey) ks.getKey(alias, hsmPassword);
                chain = new java.security.cert.Certificate[1];
                chain[0] = ks.getCertificate(alias);

            reader = new PdfReader(new ByteArrayInputStream(pdfBits));

            ByteArrayOutputStream fout = new ByteArrayOutputStream();

            PdfStamper stp = PdfStamper.createSignature(reader, fout, '\0'); 
          
            PdfSignatureAppearance sap = stp.getSignatureAppearance();

            sap.setCertificationLevel(PdfSignatureAppearance.CERTIFIED_NO_CHANGES_ALLOWED);

            sap.setRender(PdfSignatureAppearance.SignatureRenderNameAndDescription);
            sap.setCrypto(key, chain, null,PdfSignatureAppearance.WINCER_SIGNED);
            sap.setReason("Bu belgenin içeriği doğrudur ve tamdır.");
            sap.setLocation("Ankara, TR");

            Rectangle size = reader.getPageSize(1);
            size.setLeft(size.getRight() - 220);
            size.setRight(size.getRight() - 20);
            size.setBottom(size.getTop() - 70);
            size.setTop(size.getTop() - 20);
            sap.setVisibleSignature(size, 1, null);
            stp.close(); 
            
            try {
                FileOutputStream fos; 
                fos = new FileOutputStream(new File("C:/imzali_dfg.pdf")); 
                fos.write(fout.toByteArray() );
                fos.flush();
                fos.close();
            } catch ( Exception e) { 
                e.printStackTrace();
            }  

      Halil


Access your email online and on the go with Windows Live Hotmail. Sign up today. -------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/_______________________________________________
iText-questions mailing list
iText-questions@...
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php



Access your email online and on the go with Windows Live Hotmail. Sign up today.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
iText-questions mailing list
iText-questions@...
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php

imzali_dfg.pdf (123K) Download Attachment

Re: pdf signature problem on adobe reader 9

by Leonard Rosenthol :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This is an XFA-based PDF, but then you tried to add an AcroForm-based signature - the two don't (easily) mix that way...

Leonard


On Dec 2, 2008, at 8:00 AM, mustafahalil yildiz wrote:

sample is at attached..

halil




From: leonardr@...
To: itext-questions@...
Date: Mon, 1 Dec 2008 20:35:54 +0100
Subject: Re: [iText-questions] pdf signature problem on adobe reader 9

Please provide a sample PDF that demonstrates the problem.

Leonard

On Dec 1, 2008, at 2:16 PM, mustafahalil yildiz wrote:


Hi,
I sign a pdf using the code below and then when I want to open it in adobe reader 8 or previous versions it works fine and I can see the signature but when I open it with adobe reader 9.0 I couldnt see the signature what can be the problem ? can anyone help me?

                byte[] pdfBits = baos.toByteArray();
                SunPKCS11 akisProvider = new SunPKCS11(Configuration.getHSMSettings());
                Security.addProvider(akisProvider);
                KeyStore ks = KeyStore.getInstance("PKCS11", akisProvider);
                ks.load(null, hsmPassword);
                String alias = ks.aliases().nextElement();
                key = (PrivateKey) ks.getKey(alias, hsmPassword);
                chain = new java.security.cert.Certificate[1];
                chain[0] = ks.getCertificate(alias);

            reader = new PdfReader(new ByteArrayInputStream(pdfBits));

            ByteArrayOutputStream fout = new ByteArrayOutputStream();

            PdfStamper stp = PdfStamper.createSignature(reader, fout, '\0'); 
          
            PdfSignatureAppearance sap = stp.getSignatureAppearance();

            sap.setCertificationLevel(PdfSignatureAppearance.CERTIFIED_NO_CHANGES_ALLOWED);

            sap.setRender(PdfSignatureAppearance.SignatureRenderNameAndDescription);
            sap.setCrypto(key, chain, null,PdfSignatureAppearance.WINCER_SIGNED);
            sap.setReason("Bu belgenin içeriği doğrudur ve tamdır.");
            sap.setLocation("Ankara, TR");

            Rectangle size = reader.getPageSize(1);
            size.setLeft(size.getRight() - 220);
            size.setRight(size.getRight() - 20);
            size.setBottom(size.getTop() - 70);
            size.setTop(size.getTop() - 20);
            sap.setVisibleSignature(size, 1, null);
            stp.close(); 
            
            try {
                FileOutputStream fos; 
                fos = new FileOutputStream(new File("C:/imzali_dfg.pdf")); 
                fos.write(fout.toByteArray() );
                fos.flush();
                fos.close();
            } catch ( Exception e) { 
                e.printStackTrace();
            }  

      Halil


Access your email online and on the go with Windows Live Hotmail. Sign up today. -------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/_______________________________________________
iText-questions mailing list
iText-questions@...
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php



Access your email online and on the go with Windows Live Hotmail. Sign up today. <imzali_dfg.pdf>-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/_______________________________________________
iText-questions mailing list
iText-questions@...
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
iText-questions mailing list
iText-questions@...
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php

Re: pdf signature problem on adobe reader 9

by gauravkumartyagi007 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

i can make a sign at any place using the code below but when i use this for an adobe designer designed eForm (having hierarchical elements) it refuses to work and no signature got generated.


KeyStore ks = KeyStore.getInstance("pkcs12");
ks.load(new FileInputStream("my_private_key.pfx"), "my_password".toCharArray());
String alias = (String)ks.aliases().nextElement();
PrivateKey key = (PrivateKey)ks.getKey(alias, "my_password".toCharArray());
Certificate[] chain = ks.getCertificateChain(alias);
PdfReader reader = new PdfReader("original.pdf");
FileOutputStream fout = new FileOutputStream("signed.pdf");
PdfStamper stp = PdfStamper.createSignature(reader, fout, '\0');
PdfSignatureAppearance sap = stp.getSignatureAppearance();
sap.setCrypto(key, chain, null, PdfSignatureAppearance.WINCER_SIGNED);
sap.setReason("I'm the author");
sap.setLocation("Lisbon");
// comment next line to have an invisible signature
sap.setVisibleSignature(new Rectangle(100, 100, 200, 200), 1, null);
stp.close();


please help me out as it is too urgent to be done..

halil wrote:

Hi,
I sign a pdf using the code below and then when I want to open it in adobe reader 8 or previous versions it works fine and I can see the signature but when I open it with adobe reader 9.0 I couldnt see the signature what can be the problem ? can anyone help me?

                byte[] pdfBits = baos.toByteArray();
                SunPKCS11 akisProvider = new SunPKCS11(Configuration.getHSMSettings());
                Security.addProvider(akisProvider);
                KeyStore ks = KeyStore.getInstance("PKCS11", akisProvider);
                ks.load(null, hsmPassword);
                String alias = ks.aliases().nextElement();
                key = (PrivateKey) ks.getKey(alias, hsmPassword);
                chain = new java.security.cert.Certificate[1];
                chain[0] = ks.getCertificate(alias);

            reader = new PdfReader(new ByteArrayInputStream(pdfBits));

            ByteArrayOutputStream fout = new ByteArrayOutputStream();

            PdfStamper stp = PdfStamper.createSignature(reader, fout, '\0');
         
            PdfSignatureAppearance sap = stp.getSignatureAppearance();

            sap.setCertificationLevel(PdfSignatureAppearance.CERTIFIED_NO_CHANGES_ALLOWED);

            sap.setRender(PdfSignatureAppearance.SignatureRenderNameAndDescription);
            sap.setCrypto(key, chain, null,PdfSignatureAppearance.WINCER_SIGNED);
            sap.setReason("Bu belgenin içeriği doğrudur ve tamdır.");
            sap.setLocation("Ankara, TR");

            Rectangle size = reader.getPageSize(1);
            size.setLeft(size.getRight() - 220);
            size.setRight(size.getRight() - 20);
            size.setBottom(size.getTop() - 70);
            size.setTop(size.getTop() - 20);
            sap.setVisibleSignature(size, 1, null);
            stp.close();
           
            try {
                FileOutputStream fos;
                fos = new FileOutputStream(new File("C:/imzali_dfg.pdf"));
                fos.write(fout.toByteArray() );
                fos.flush();
                fos.close();
            } catch ( Exception e) {
                e.printStackTrace();
            }  

      Halil

_________________________________________________________________
Access your email online and on the go with Windows Live Hotmail.
http://windowslive.com/Explore/Hotmail?ocid=TXT_TAGLM_WL_hotmail_acq_access_112008
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php