@@ -0,0 +1,1951 @@
+package de.alpharogroup.crypto.key.writer;%0A%0Aimport java.io.File;%0Aimport java.io.FileOutputStream;%0Aimport java.io.IOException;%0Aimport java.io.OutputStream;%0Aimport java.security.cert.CertificateEncodingException;%0Aimport java.security.cert.X509Certificate;%0A%0Aimport org.apache.commons.codec.binary.Base64;%0A%0Aimport lombok.NonNull;%0A%0A/**%0A * The class %7B@link CertificateWriter%7D is a utility class for write certificates%0A * in files or streams.%0A */%0Apublic class CertificateWriter %7B%0A%0A%09/**%0A%09 * Write the given %7B@link X509Certificate%7D into the given %7B@link File%7D in%0A%09 * the *.pem format.%0A%09 *%0A%09 * @param certificate%0A%09 *            the certificate%0A%09 * @param file%0A%09 *            the file to write in%0A%09 * @throws IOException%0A%09 *             Signals that an I/O exception has occurred.%0A%09 * @throws CertificateEncodingException%0A%09 *             is thrown if an encoding error occurs.%0A%09 */%0A%09public static void write(final X509Certificate certificate, final @NonNull File file)%0A%09%09%09throws IOException, CertificateEncodingException %7B%0A%09%09write(certificate, new FileOutputStream(file));%0A%09%7D%0A%0A%09/**%0A%09 * Write the given %7B@link X509Certificate%7D into the given%0A%09 * %7B@link OutputStream%7D in the *.pem format.%0A%09 *%0A%09 * @param certificate%0A%09 *            the certificate%0A%09 * @param outputStream%0A%09 *            the output stream to write in%0A%09 * @throws IOException%0A%09 *             Signals that an I/O exception has occurred.%0A%09 * @throws CertificateEncodingException%0A%09 *             is thrown if an encoding error occurs.%0A%09 */%0A%09public static void write(final X509Certificate certificate, final @NonNull OutputStream outputStream)%0A%09%09%09throws IOException, CertificateEncodingException %7B%0A%09%09final byte%5B%5D certificateBytes = certificate.getEncoded();%0A%09%09outputStream.write(%22-----BEGIN CERTIFICATE-----%5Cn%22.getBytes(%22US-ASCII%22));%0A%09%09outputStream.write(Base64.encodeBase64(certificateBytes, true));%0A%09%09outputStream.write(%22-----END CERTIFICATE-----%5Cn%22.getBytes(%22US-ASCII%22));%0A%09%09outputStream.close();%0A%09%7D%0A%7D%0A

Create CertificateWriter.java