My code, maybe that's makes it clearer:
import com.lowagie.text.Rectangle;
import com.lowagie.text.pdf.PdfReader;
import com.lowagie.text.pdf.PdfSignatureAppearance;
import com.lowagie.text.pdf.PdfStamper;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.PrivateKey;
import java.security.cert.Certificate;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class test
{
public test()
{
}
public static void main(String[] args) throws Exception
{
BufferedReader br = new BufferedReader(new
InputStreamReader(System.in));
System.out.print("Keystore Password: ");
String keystore_password = br.readLine();
System.out.print("Password: ");
String password = br.readLine();
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
ks.load(new FileInputStream("d:\\test\\test.ks"),
keystore_password.toCharArray());
String alias = (String) ks.aliases().nextElement();
PrivateKey key = (PrivateKey) ks.getKey(alias,
password.toCharArray());
Certificate[] chain = ks.getCertificateChain(alias);
PdfReader reader = new PdfReader("d:\\test\\test.pdf");
FileOutputStream fout = new FileOutputStream("d:\\test\\signed.pdf");
PdfStamper stp = PdfStamper.createSignature(reader, fout, '\0');
PdfSignatureAppearance sap = stp.getSignatureAppearance();
sap.setCrypto(key, chain, null, PdfSignatureAppearance.SELF_SIGNED);
sap.setReason("I'm the author");
sap.setLocation("Here");
sap.setCertified(true);
// comment next line to have an invisible signature
//sap.setVisibleSignature(new Rectangle(100, 100, 200, 200), 1, null);
stp.close();
}
}
greetings,
Paul
bruno wrote:
> Paul van der Linden wrote:
>
>
>> Hi,
>> I want to use itext for signing a pdf. When I sign it with itext, and
>> import the certificate in adobe, the signature is validating.
>>
>> When I just at this instruction: sap.setCertified(true). so the pdf
>> can't be edited without the signature removed.
>> The problem is, when I do that, I get the following error in adobe
>> acrobat reader:
>> ---------------------------------------------------------
>> Error during signature verification.
>>
>> Unknown error
>> Support Information: CDSHandler-358
>> ---------------------------------------------------------
>> What am I doing wrong?
>>
>>
> I have never seen that kind of error, nor has Google.
> br,
> Bruno
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> iText-questions mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
>
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions