Current location - Quotes Website - Signature design - Get the public key in CSR certificate file
Get the public key in CSR certificate file
For example, the csr certificate file contains a public key and the signature of the CA organization on this public key, so it is not a real public key to open the CSR file directly in text, and the real public key needs to be obtained in a certain way:

Public static string convertpemtopkcs10 Certification Request (string path) (

InputStream? Input = new FileInputStream (path);

security . add provider(new org . bouncy castle . JCE . provider . bouncy castle provider());

PEM reader PEM reader = new PEM reader(new InputStreamReader(input));

PEM parser PEM parser = new PEM parser(PEM reader);

pkcs 10 certification request CSR = null;

string writer output = new string writer();

Try {

CSR = new pkcs 10 certification request(PEM parser . readpemobject()。 get content());

Pembobject pkpemobject = new pemobject ("public key",

csr.getSubjectPublicKeyInfo()。 get encoded());

Pemwriter pemwriter = new pemwriter (output);

PEM writer . writeobject(pkPemObject);

PEM writer . close();

log . debug(" PEM parser returned:"+output . get buffer());

} catch (IOException ex) {

log.error("IOException,convertPemToPublicKey ",ex);

}

Returns output.getBuffer (). toString();

}