[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[iaik-jce] Help: Creating CSR Error



Hi all,
i have create a CSR in based64 format.but it can' be accepted by VersSign.
what can i do?
follows is the code.
 
i do insert the tab, -----BEGIN NEW CERTIFICATE REQUEST-----
and -----END NEW CERTIFICATE REQUEST-----
 
 
 
 KeyPairGenerator keyGen = KeyPairGenerator.getInstance(encodeAlg, proivder);
 keyGen.initialize(keyLen, new SecureRandom());
 KeyPair keyPair = keyGen.generateKeyPair();
 prvKey = keyPair.getPrivate();
 pubKey = keyPair.getPublic();
 
 Name subject = new Name();
 subject.addRDN(ObjectID.country, "AT");
 subject.addRDN(ObjectID.locality, "Graz");
 subject.addRDN(ObjectID.organization ,"TU Graz");
 subject.addRDN(ObjectID.organizationalUnit ,"IAIK");
 subject.addRDN(ObjectID.commonName ,"TestUser");
 
 CertificateRequest certReq = new CertificateRequest(pubKey, subject);
 certReq.sign(AlgorithmID.md5WithRSAEncryption, prvKey);
 System.out.print(certReq.toString());
 
 
 
 Base64OutputStream base64os = new Base64OutputStream(new FileOutputStream("test"));
 byte[] data = certReq.toString().getBytes();
 base64os.write(data); base64os.flush();
 base64os.close();
 
 if (certReq.verify())
 { System.out.print("vertify OK!"); }