// Path: java-ca-lib/src/main/java/io/github/olivierlemasle/ca/CA.java
// public static RootCertificateBuilder createSelfSignedCertificate(
//     final DistinguishedName subject) {
//   return new RootCertificateBuilderImpl(subject);
// }
// 
// Path: java-ca-lib/src/main/java/io/github/olivierlemasle/ca/CA.java
// public static DnBuilder dn() {
//   return new DnBuilderImpl();
// }
// 
// Path: java-ca-lib/src/main/java/io/github/olivierlemasle/ca/CA.java
// public static CsrLoader loadCsr(final File csrFile) {
//   return new CsrLoaderImpl(csrFile);
// }
// 
// Path: java-ca-lib/src/main/java/io/github/olivierlemasle/ca/CSR.java
// public interface CSR {
// 
//   public DistinguishedName getSubject();
// 
//   public PublicKey getPublicKey();
// 
// }
// 
// Path: java-ca-lib/src/main/java/io/github/olivierlemasle/ca/Certificate.java
// public interface Certificate {
// 
//   public X509Certificate getX509Certificate();
// 
//   public String print();
// 
//   public void save(File file);
// 
//   public void save(String fileName);
// 
//   public CertificateWithPrivateKey attachPrivateKey(PrivateKey privateKey);
// 
// }
// 
// Path: java-ca-lib/src/main/java/io/github/olivierlemasle/ca/DistinguishedName.java
// public interface DistinguishedName {
// 
//   public X500Name getX500Name();
// 
//   public X500Principal getX500Principal();
// 
//   public byte[] getEncoded();
// 
//   public String getName();
// }
// 
// Path: java-ca-lib/src/main/java/io/github/olivierlemasle/ca/RootCertificate.java
// public interface RootCertificate extends CertificateWithPrivateKey {
// 
//   public Signer signCsr(final CSR request);
// 
// }


import static io.github.olivierlemasle.ca.CA.createSelfSignedCertificate;
import static io.github.olivierlemasle.ca.CA.dn;
import static io.github.olivierlemasle.ca.CA.loadCsr;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeFalse;
import static org.junit.Assume.assumeTrue;
import java.io.File;
import java.io.IOException;
import java.lang.ProcessBuilder.Redirect;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import javax.net.ssl.SSLContext;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.ssl.SSLContexts;
import org.apache.http.util.EntityUtils;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import io.github.olivierlemasle.ca.CSR;
import io.github.olivierlemasle.ca.Certificate;
import io.github.olivierlemasle.ca.DistinguishedName;
import io.github.olivierlemasle.ca.RootCertificate;
package io.github.olivierlemasle.tests.it;






public class OpenSslIT {

  @BeforeClass
  @AfterClass
  public static void clean() {
    final File caCertPath = new File("ca.cer");
    caCertPath.delete();
    final File reqPath = new File("CSR.csr");
    reqPath.delete();
    final File keyPath = new File("private.key");
    keyPath.delete();
    final File certPath = new File("cert.cer");
    certPath.delete();
  }

  @Before
  public void checkPlatform() {
    assumeFalse(TestUtils.isWindows());
    assumeTrue(TestUtils.opensslExists());
  }

  @Test
  public void completeTest() throws IOException, InterruptedException, NoSuchAlgorithmException,
      KeyStoreException, KeyManagementException, CertificateException {
    // Create a self-signed root certificate
    System.out.println("Generate ..");
    final DistinguishedName rootDn = dn("CN=CA-Test");
// Path: java-ca-lib/src/main/java/io/github/olivierlemasle/ca/CA.java
// public static RootCertificateBuilder createSelfSignedCertificate(
//     final DistinguishedName subject) {
//   return new RootCertificateBuilderImpl(subject);
// }
// 
// Path: java-ca-lib/src/main/java/io/github/olivierlemasle/ca/CA.java
// public static DnBuilder dn() {
//   return new DnBuilderImpl();
// }
// 
// Path: java-ca-lib/src/main/java/io/github/olivierlemasle/ca/CA.java
// public static CsrLoader loadCsr(final File csrFile) {
//   return new CsrLoaderImpl(csrFile);
// }
// 
// Path: java-ca-lib/src/main/java/io/github/olivierlemasle/ca/CSR.java
// public interface CSR {
// 
//   public DistinguishedName getSubject();
// 
//   public PublicKey getPublicKey();
// 
// }
// 
// Path: java-ca-lib/src/main/java/io/github/olivierlemasle/ca/Certificate.java
// public interface Certificate {
// 
//   public X509Certificate getX509Certificate();
// 
//   public String print();
// 
//   public void save(File file);
// 
//   public void save(String fileName);
// 
//   public CertificateWithPrivateKey attachPrivateKey(PrivateKey privateKey);
// 
// }
// 
// Path: java-ca-lib/src/main/java/io/github/olivierlemasle/ca/DistinguishedName.java
// public interface DistinguishedName {
// 
//   public X500Name getX500Name();
// 
//   public X500Principal getX500Principal();
// 
//   public byte[] getEncoded();
// 
//   public String getName();
// }
// 
// Path: java-ca-lib/src/main/java/io/github/olivierlemasle/ca/RootCertificate.java
// public interface RootCertificate extends CertificateWithPrivateKey {
// 
//   public Signer signCsr(final CSR request);
// 
// }


// Path: java-ca-lib/src/test/java/io/github/olivierlemasle/tests/it/OpenSslIT.java
import static io.github.olivierlemasle.ca.CA.createSelfSignedCertificate;
import static io.github.olivierlemasle.ca.CA.dn;
import static io.github.olivierlemasle.ca.CA.loadCsr;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeFalse;
import static org.junit.Assume.assumeTrue;
import java.io.File;
import java.io.IOException;
import java.lang.ProcessBuilder.Redirect;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import javax.net.ssl.SSLContext;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.ssl.SSLContexts;
import org.apache.http.util.EntityUtils;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import io.github.olivierlemasle.ca.CSR;
import io.github.olivierlemasle.ca.Certificate;
import io.github.olivierlemasle.ca.DistinguishedName;
import io.github.olivierlemasle.ca.RootCertificate;

package io.github.olivierlemasle.tests.it;






public class OpenSslIT {

  @BeforeClass
  @AfterClass
  public static void clean() {
    final File caCertPath = new File("ca.cer");
    caCertPath.delete();
    final File reqPath = new File("CSR.csr");
    reqPath.delete();
    final File keyPath = new File("private.key");
    keyPath.delete();
    final File certPath = new File("cert.cer");
    certPath.delete();
  }

  @Before
  public void checkPlatform() {
    assumeFalse(TestUtils.isWindows());
    assumeTrue(TestUtils.opensslExists());
  }

  @Test
  public void completeTest() throws IOException, InterruptedException, NoSuchAlgorithmException,
      KeyStoreException, KeyManagementException, CertificateException {
    // Create a self-signed root certificate
    System.out.println("Generate ..");
    final DistinguishedName rootDn = dn("CN=CA-Test");
    final RootCertificate root = createSelfSignedCertificate(rootDn).build();