Certificate Signing
hi All,
i want to sign certificate. this certificate is my own created and sign that certificate in command prompt with the help of :-
keytool -certreq -alias alias -sigalg rsa -keystore keystore.
this command execute and gives on String like:-
--begin
asdfasdfasdasdf
aadsfasdfasdffadsff
asdfasdffasdfasdaasd
--end-
if i want to do same in application.
so plz help me.
its urgent
[453 byte] By [
DaveAnjana] at [2007-11-26 16:49:12]

# 1
The string you get from keytool is the Certificate Signing Request (CSR) of your certificate with alias "alias". I don't know if there are some sun's library to get it but i know that geromino (http://geronimo.apache.org) has all you need. The csr is a base-64 rappresentation of the pkcs10 certification request resulting from a X509Certificate rappresentation. If cert is the given certificate (you get from the KeyStore) and privateKey is the certificate's privatekey a snippet of code to get the csr would be:
String sigalg = cert.getSigAlgName();
X509Name subject = new X509Name(cert.getSubjectDN().toString());
PublicKey publicKey = cert.getPublicKey();
ASN1Set attributes = null;
PKCS10CertificationRequest csr = new PKCS10CertificationRequest(sigalg, subject, publicKey, attributes, signingKey);
ByteArrayOutputStream os = new ByteArrayOutputStream();
DEROutputStream deros = new DEROutputStream(os);
deros.writeObject(csr.getDERObject());
String b64 = new String(Base64.encode(os.toByteArray()));
b64 is the string you are looking for.