Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It depends on what you mean by "ASCII format". But generally you can do something like that:</p> <pre><code>// Read the CSR FileReader fileReader = new FileReader("/path/to/your.csr"); PemReader pemReader = new PemReader(fileReader); PKCS10CertificationRequest csr = new PKCS10CertificationRequest(pemReader.readPemObject().getContent()); pemReader.close(); fileReader.close(); // Write the Public Key as a PEM-File StringWriter output = new StringWriter(); PemWriter pemWriter = new PemWriter(output); PemObject pkPemObject = new PemObject("PUBLIC KEY", csr.getSubjectPublicKeyInfo().getEncoded()); pemWriter.writeObject(pkPemObject); pemWriter.close(); System.out.println(output.getBuffer()); // Extract the Public Key as "RSAKeyParameters" so you can use for // encryption/signing operations. RSAKeyParameters pubkey = (RSAKeyParameters)PublicKeyFactory.createKey(csr.getSubjectPublicKeyInfo()); </code></pre> <p>This is what you'll get: </p> <pre><code>-----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxlRixVjOXAmUQ2zORREO VSQDQejyjWzT3bDznPltiPMwM3SOmPmZyrB8jF3iFvzdFge1QG2WdDj7PzmysXNL /1xRa0efWv8nURx1eV86hvU6ThNqY3WPyYYXSjTcN74uhGSJo7d5zG6JSL4Cj+l4 RO+nh/5Pa8438ufS+9hXndKPFT2aub9roKysxWpsctpNoOIjfyxkLv9Z9sqxuggG nwYkwYmoDjPAQp2gRpCp7Hw5F6jSkA33NR5S/aPdyvzKZDbuoRdAl2sTubL1TLG3 nC6tetGsmFRRkNiJjPSNtbXXtN6RB2eJL0epyaFFLksFBaL6nvYIgB1uqFroUY15 2QIDAQAB -----END PUBLIC KEY----- </code></pre> <p>I have tested this with the latest version of the BC-provider. You need both the "provider" and the "PKIX/PKCS..." jar (otherwise you have to deal with deprecated API-calls).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload