Anyone have any suggestions here? Or is there somewhere else to ask
itextsharp questions? 

I am baffled and have no idea what/how to test.

Is it a code problem? A bad .pfx file?

Again ... worked with older version of itextsharp, upgraded to the latest
release and made some changes as necessary for the new itextsharp syntax.
This is essentially the same code I have seen everywhere for handling
signatures. I have tested with a few different .pfx files that I have with
the same result.

Would appreciate any help I can get or sample code in the lastest itextsharp
that works (not sure it would be any different than below).

I basically need to figure out why I am getting:

Org.BouncyCastle.Security.Certificates.CertificateException:
System.IndexOutOfRangeException: Index was outside the bounds of the array.

Kevin

---------------------

Message: 6
Date: Tue, 5 Feb 2008 00:33:49 -0800
From: "Kevin Brown" <[EMAIL PROTECTED]>
Subject: [iText-questions] Help with itextsharp and security
To: <itext-questions@lists.sourceforge.net>
Message-ID: <[EMAIL PROTECTED]@xportability.com>
Content-Type: text/plain;       charset="us-ascii"

I had an application that worked with an older version of iText. I updated
the reference to the newest version of itextsharp and made appropriate code
changes (i.e. getKey to GetKey ...)

I cannot figure out what the error is that I get (I apologize as I don't
really understand all the nuances of the Certification code ..)

My code is (essentially the same as many other examples):

        private void processCert()
        {
            string alias = null;
            char[] mypassword = this.password.ToCharArray();
            Pkcs12Store pk12 = new Pkcs12Store(new FileStream(this.Path,
FileMode.Open, FileAccess.Read), mypassword);
            IEnumerator i = pk12.Aliases.GetEnumerator();
            while (i.MoveNext())
            {
                alias = ((string)i.Current);
                if (pk12.IsKeyEntry(alias))
                    break;
            }

            this.akp = pk12.GetKey(alias).Key;
            X509CertificateEntry[] ce = pk12.GetCertificateChain(alias);
            this.chain = new X509Certificate[ce.Length];
            for (int k = 0; k < ce.Length; ++k)
                chain[k] = ce[k].Certificate;
        }

What use to work before, now trips an error at the line:

            Pkcs12Store pk12 = new Pkcs12Store(new FileStream(this.Path,
FileMode.Open, FileAccess.Read), mypassword);

Stopping code at this line and checking this.Path and mypassword and they
are exactly correct. Stepping past this line yields an error.

This is using the exact same .pfx file and password I used with the older
itextsharp. The error is:

Error : please make sure you entered a valid certificate file and password
Exception : Org.BouncyCastle.Security.Certificates.CertificateException:
System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at Org.BouncyCastle.Asn1.X509.X509Name..ctor(Asn1Sequence seq)
   at Org.BouncyCastle.Asn1.X509.X509Name.GetInstance(Object obj)
   at Org.BouncyCastle.Asn1.X509.TbsCertificateStructure..ctor(Asn1Sequence
seq)
   at Org.BouncyCastle.Asn1.X509.TbsCertificateStructure.GetInstance(Object
obj)
   at Org.BouncyCastle.Asn1.X509.X509CertificateStructure..ctor(Asn1Sequence
seq)
   at Org.BouncyCastle.Asn1.X509.X509CertificateStructure.GetInstance(Object
obj)
   at
Org.BouncyCastle.X509.X509CertificateParser.ReadDerCertificate(Asn1InputStre
am dIn)
   at Org.BouncyCastle.X509.X509CertificateParser.ReadCertificate(Stream
inStream)
   at Org.BouncyCastle.X509.X509CertificateParser.ReadCertificate(Stream
inStream)
   at Org.BouncyCastle.X509.X509CertificateParser.ReadCertificate(Byte[]
input)
   at Org.BouncyCastle.Pkcs.Pkcs12Store..ctor(Stream input, Char[] password)
   at PDFTools.Cert.processCert() in
D:\foActive\Projects\PDFTools\iTextSharpSign\PDFSigner.cs:line 59
   at PDFTools.Cert..ctor(String cpath, String cpassword) in
D:\foActive\Projects\PDFTools\iTextSharpSign\PDFSigner.cs:line 89
   at PDFTools.Form1.butSign_Click(Object sender, EventArgs e) in
D:\foActive\Projects\PDFTools\iTextSharpSign\Form1.cs:line 456

Would appreciate any help/pointers I can get as I would like to update this
application to the latest itextsharp. Is the certificate just not compatible
with this version but was OK in the old version?

Kevin Brown
CEO, Xportability LLC
(650) 327-1000 Direct
(650) 328-8008 Fax
(925) 395-1772 Mobile
skype:kbrown01
[EMAIL PROTECTED]


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to