Je cherche une clé privée dans le LdAP à partir des paramétres
j'ai toujours des exceptions et je ne comprend pas pourquoi .
quelqu'un peut me donner une idée pour corriger ca
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
Exception in thread "main" java.security.spec.InvalidKeySpecException: java.security.InvalidKeyException: IOException : DER input, Integer tag error
	at sun.security.rsa.RSAKeyFactory.engineGeneratePrivate(Unknown Source)
	at java.security.KeyFactory.generatePrivate(Unknown Source)
	at CertificationAuthority.CA.getCAFromLDAP(CA.java:812)
	at CertificationAuthority.CA.main(CA.java:1020)
Caused by: java.security.InvalidKeyException: IOException : DER input, Integer tag error
	at sun.security.pkcs.PKCS8Key.decode(Unknown Source)
	at sun.security.pkcs.PKCS8Key.decode(Unknown Source)
	at sun.security.rsa.RSAPrivateCrtKeyImpl.<init>(Unknown Source)
	at sun.security.rsa.RSAPrivateCrtKeyImpl.newKey(Unknown Source)
	at sun.security.rsa.RSAKeyFactory.generatePrivate(Unknown Source)
	... 4 more

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
        SearchResult sr = (SearchResult)answer.next();
 
			        if (sr.getAttributes() != null) {
 
 
			        	Attributes attributes = sr.getAttributes();
		                Attribute attr = attributes.get("privateKey");
		                String s = (String) attr.get();
		                byte[] cps = s.getBytes();
		                KeyFactory keyFactory = KeyFactory.getInstance("RSA");
		                EncodedKeySpec privateKeySpec = new PKCS8EncodedKeySpec(cps);
		                pk = keyFactory.generatePrivate(privateKeySpec);
 
 
				    }