Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » iText »

Re: [iText-questions] A problem about inserting digital signature
 withiTextSharp

Paulo Soares

2007-06-25


I'll answer this in the iTextSharp mailing list given that you posted in
both lists.

Paulo

> -----Original Message-----
> From: itext-questions-bounces@(protected)
> [mailto:itext-questions-bounces@(protected)
> Behalf Of Seung Hyun Park
> Sent: Monday, June 25, 2007 2:20 PM
> To: itext-questions@(protected)
> Subject: [iText-questions] A problem about inserting digital
> signature withiTextSharp
>
> Hello.
>
> I have made a program related to PDF digital signing with iTextSharp.
>
> I already read "How to sign a PDF using iText and iTextSharp" tutorial
> and some postings in the mailing list.
>
> But, I could not succeed in inserting digital signature at
> existing PDF files.
>
>
> My test codes are as followings (it was from the C# sample of iText
> mailing list.);
>
> -------------------
>
>
> Private Sub Test1()
>
>      Dim [alias] As String = "Dark"
>      Dim pk12 As New Pkcs12Store(New FileStream("myTestKey.pfx",
> FileMode.Open, FileAccess.Read, FileShare.ReadWrite),
> "1234".ToCharArray())
>
>      'Below codes were commented because an invalid
> Casting error occurred.
>      '-------------------
>      'Dim i As IEnumerator = pk12.Aliases() '-> generate
> invalid cast error
>
>      'While i.MoveNext()
>      '   [alias] = CStr(i.Current)
>      '   If pk12.IsKeyEntry([alias]) Then
>      '     Exit While
>      '   End If
>      'End While
>      '---------------------
>
>      Dim akp As AsymmetricKeyParameter = pk12.GetKey([alias]).Key
>      Dim ce As X509CertificateEntry() =
> pk12.GetCertificateChain([alias])
>      Dim chain(ce.Length) As X509Certificate
>      Dim k As Integer
>
>      While k < ce.Length
>         chain(k) = ce(k).Certificate
>         k += 1
>      End While
>
>      Dim reader As New PdfReader("unsigned_signature_field.pdf")
>
>      Dim st As PdfStamper = PdfStamper.CreateSignature(reader, New
> FileStream("output.pdf", FileMode.Create, FileAccess.Write), "\0",
> vbNullString, True)
>      Dim sap As PdfSignatureAppearance = st.SignatureAppearance
>
>      sap.SetCrypto(akp, chain, Nothing,
> PdfSignatureAppearance.WINCER _SIGNED)
>      sap.Reason = "My Signature"
>      sap.Location = "Universe"
>      sap.SetVisibleSignature("foobarsig")
>
>      st.Close()      '-> Null reference exception error
> is occurred.
>
>   End Sub
>
> ----------------------------------
>
> An invalid casting error and a null reference exception occurred.
>
> I added comments wherer error was generated in the above codes.
>
>
>
> My testing environments were as this;
>
> 1. I used the latest iTextSharp and BouncyCastle.
>
> 2. My test program was compiled with VS 2003.
>
> 3. I made a pfx file using KeyTool GUI 1.7 and an input file using
> Acrobat 8 Pro.
>
>
>
> I attached my full testing codes, testing key and input files.
>
>
>
> By the way, could you tell me how to sign for self signed
> mode with iTextSharp?
>
> I do now know how to sign although I already read related postings
> because most of them were for JDK; Keystore does not exist at .NET
> framework.
>
>
>
> If you could take a few minutes to answer my questions, I would really
> appreciate it.
>
> Thank you in advance for your help.
>
>
> Best regards,
>
> S. H. Park
>


Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter informação confidencial ou legalmente protegida. A incorrecta transmissão desta mensagem não significa a perca de confidencialidade. Se esta mensagem for recebida por engano, por favor envie-a de volta para o remetente e apague-a do seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de usar, revelar ou distribuir qualquer parte desta mensagem.

Disclaimer:
This message is destined exclusively to the intended receiver. It may contain confidential or legally protected information. The incorrect transmission of this message does not mean the loss of its confidentiality. If this message is received by mistake, please send it back to the sender and delete it from your system immediately. It is forbidden to any person who is not the intended receiver to use, distribute or copy any part of this message.


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
iText-questions mailing list
iText-questions@(protected)
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/
©2008 junlu.com - Jax Systems, LLC, U.S.A.