Package org.bouncycastle.openssl

Examples of org.bouncycastle.openssl.PEMWriter.writeObject()


    try {
      StringWriter stringWriter = new StringWriter();

      PEMWriter writer = new PEMWriter(stringWriter, BouncyCastleLoader.getName());
      for (X509Certificate cert : certs) {
        writer.writeObject(cert);
      }
      writer.close();

      String s = stringWriter.toString();
      return s;
View Full Code Here


  public static String serialize(KeyPair keyPair) throws IOException {
    StringWriter writer = new StringWriter();
    PEMWriter pemWriter = new PEMWriter(writer, BouncyCastleLoader.getName());
    try {
      pemWriter.writeObject(keyPair);
      pemWriter.flush();
      return writer.toString();
    } finally {
      IoUtils.safeClose(pemWriter);
    }
View Full Code Here

          .info("CERTIFICATE PEM (to store in a certificate.pem file)");
      UGateUtil.PLAIN_LOGGER
          .info("======================================================");
      try (final PEMWriter pemWriter = new PEMWriter(new PrintWriter(
          System.out))) {
        pemWriter.writeObject(cert);
        pemWriter.flush();
        UGateUtil.PLAIN_LOGGER
            .info("======================================================");
        UGateUtil.PLAIN_LOGGER
            .info("PRIVATE KEY PEM (to store in a private.pem file)");
View Full Code Here

            .info("======================================================");
        UGateUtil.PLAIN_LOGGER
            .info("PRIVATE KEY PEM (to store in a private.pem file)");
        UGateUtil.PLAIN_LOGGER
            .info("======================================================");
        pemWriter.writeObject(privateKey);
        pemWriter.flush();
      } catch (final Throwable t) {
        log.warn("Unable to dump certificate private PEM", t);
      }
    } catch (final Throwable t) {
View Full Code Here

            try
            {
                for (int i = 0; i != certificates.size(); i++)
                {
                    pWrt.writeObject(certificates.get(i));
                }
           
                pWrt.close();
            }
            catch (Exception e)
View Full Code Here

        return null;
    }

    protected void doWriteKeyPair(KeyPair kp, OutputStream os) throws Exception {
        PEMWriter w = new PEMWriter(new OutputStreamWriter(os));
        w.writeObject(kp);
        w.flush();
    }

}
View Full Code Here

                fos = new FileOutputStream(PRIVATE_KEY_FILE_PATH);
                StringWriter stringWriter = new StringWriter();

                /* Write in PEM format (openssl support) */
                PEMWriter pemFormatWriter = new PEMWriter(stringWriter);
                pemFormatWriter.writeObject(keypair.getPrivate());
                pemFormatWriter.close();
                fos.write(stringWriter.toString().getBytes());
            } catch (IOException ioe) {
                throw ioe;
            } finally {
View Full Code Here

       
        /*
         * Write in PEM format (openssl support)
         */
        PEMWriter pemFormatWriter = new PEMWriter(stringWriter);
        pemFormatWriter.writeObject(keypair.getPrivate());
        pemFormatWriter.close();
        fos.write(stringWriter.toString().getBytes());
      } catch (IOException ioe) {
        throw ioe;
      } finally {
View Full Code Here

        // PKCS7
        //
        ByteArrayOutputStream bOut = new ByteArrayOutputStream();
        PEMWriter             pWrt = new PEMWriter(new OutputStreamWriter(bOut));
       
        pWrt.writeObject(d);
       
        pWrt.close();
       
        pemRd = new PEMReader(new InputStreamReader(new ByteArrayInputStream(bOut.toByteArray())));
        d = (ContentInfo)pemRd.readObject();   
View Full Code Here

    {
        PEMReader pemRd;
        ByteArrayOutputStream bOut = new ByteArrayOutputStream();
        PEMWriter             pWrt = new PEMWriter(new OutputStreamWriter(bOut));
       
        pWrt.writeObject(pair.getPublic());
       
        pWrt.close();

        pemRd = new PEMReader(new InputStreamReader(new ByteArrayInputStream(bOut.toByteArray())));
       
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.