mardi 29 avril 2014

checking bouncycastle certificate request for keyUsage


Vote count:

0




How can I check my certificate Request to see if a particular KeyUsage is set?


I used the following method but somehow get a weird error that: java.lang.NoSuchMethodError: org.bouncycastle.asn1.x509.KeyUsage.hasUsages(I)Z


Here is my method:



private boolean check_keyusage( PKCS10CertificationRequest request) throws IOException {
Attribute[] attr = request.getAttributes(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest);
System.out.println("attr.length = "+attr.length);
// for(int i = 0;i<attr.length;i++){
ASN1Encodable[] ext = attr[0].getAttributeValues();
System.out.println("ext.length = "+ext.length);
// for(int j = 0;j<ext.length;j++){
keyusage = KeyUsage.fromExtensions(Extensions.getInstance(ext[0]));
// }
// }
return keyusage.hasUsages(KeyUsage.digitalSignature);
}


I know there is only one extension request attribute that is set(KeyUsage). Therefore I have commented the loop.Is there a better way to do this?


Thanks



asked 1 min ago






Aucun commentaire:

Enregistrer un commentaire