Hello,

Still discovering Digital Signatures for PDF documents, I'm trying to run Code 
sample 4.1 from http://itextpdf.com/book/digitalsignatures20121017.pdf

Getting following error when running code from Netbeans on windows2003 32bit 
platform (java 7 & iText 5.3.4) :

public static void main (String[] args) throws GeneralSecurityException, 
com.itextpdf.text.DocumentException, DocumentException, FileNotFoundException, 
IOException {
            Properties properties = new Properties();
                    try {
                        properties.load(new FileInputStream(PROPS));
                    } catch (IOException ex) {
                        
Logger.getLogger(SignWithPKCS11HSM.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    char[] pass = 
properties.getProperty("PASSWORD").toCharArray();
                    String pkcs11cfg = properties.getProperty("PKCS11CFG");
                    BouncyCastleProvider providerBC = new 
BouncyCastleProvider();
                    Security.addProvider(providerBC);
                    FileInputStream fis = new FileInputStream(pkcs11cfg);
                    Provider providerPKCS11 = new SunPKCS11(fis);
                    Security.addProvider(providerPKCS11);
                    KeyStore ks;
                    try {
                        ks = KeyStore.getInstance("PKCS11");
                        ks.load(null, pass);
134:                String alias = (String)ks.aliases().nextElement();
                        PrivateKey pk;
                        pk = (PrivateKey)ks.getKey(alias, pass);
                        Certificate[] chain = ks.getCertificateChain(


Exception in thread "main" java.util.NoSuchElementException
        at java.util.HashMap$HashIterator.nextEntry(HashMap.java:809)
        at java.util.HashMap$KeyIterator.next(HashMap.java:841)
        at java.util.Collections$2.nextElement(Collections.java:3657)
        at 
com.alliacom.crypto.luna.SignWithPKCS11HSM.main(SignWithPKCS11HSM.java:134)


I'm pretty sure my HSM is ok because following code runs just fine because I 
can sign raw data with iaik.pkcs.pkcs11.wrapper  and having good feed-back from 
following lines:

                    /*String config = "name=LunaSA\n"
                    + "library=" + DLL + "\n"
                    + "slotListIndex = " + getSlotsWithTokens(DLL)[0];
                    ByteArrayInputStream bais = new 
ByteArrayInputStream(config.getBytes());
                    Provider providerPKCS11 = new SunPKCS11(bais);*/

slot: 1
manufacturerID: Safenet, Inc.
model: LunaSA
slot: 2
manufacturerID: Safenet, Inc.
model: LunaSA

Could you please help me ?


Laurent


________________________________

Le papier est un support de communication naturel, renouvelable et recyclable. 
Si vous devez imprimer ce mail, n’oubliez pas de le recycler.
------------------------------------------------------------------------------
Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and
much more. Get web development skills now with LearnDevNow -
350+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122812
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to