Search in sources :

Example 1 with SelfSignedCertificateFactory

use of org.neo4j.test.ssl.SelfSignedCertificateFactory in project neo4j by neo4j.

the class CertificatesIT method setup.

@BeforeAll
public static void setup() throws IOException, GeneralSecurityException, OperatorCreationException {
    certFactory = new SelfSignedCertificateFactory();
    keyFile = Files.createTempFile("key", "pem");
    certFile = Files.createTempFile("key", "pem");
    // make sure files are not there
    Files.delete(keyFile);
    Files.delete(certFile);
    certFactory.createSelfSignedCertificate(certFile, keyFile, "my.domain");
    util = new TransportTestUtil();
}
Also used : TransportTestUtil(org.neo4j.bolt.testing.TransportTestUtil) SelfSignedCertificateFactory(org.neo4j.test.ssl.SelfSignedCertificateFactory) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 2 with SelfSignedCertificateFactory

use of org.neo4j.test.ssl.SelfSignedCertificateFactory in project neo4j by neo4j.

the class RoutingConnectorCertificatesIT method setUp.

@BeforeAll
public static void setUp() throws IOException, GeneralSecurityException, OperatorCreationException {
    certFactory = new SelfSignedCertificateFactory();
    externalKeyFile = Files.createTempFile("key", "pem");
    externalCertFile = Files.createTempFile("key", "pem");
    // make sure files are not there
    Files.delete(externalKeyFile);
    Files.delete(externalCertFile);
    certFactory.createSelfSignedCertificate(externalCertFile, externalKeyFile, "my.domain");
    internalKeyFile = Files.createTempFile("key", "pem");
    internalCertFile = Files.createTempFile("key", "pem");
    // make sure files are not there
    Files.delete(internalKeyFile);
    Files.delete(internalCertFile);
    certFactory.createSelfSignedCertificate(internalCertFile, internalKeyFile, "my.domain");
    util = new TransportTestUtil();
}
Also used : TransportTestUtil(org.neo4j.bolt.testing.TransportTestUtil) SelfSignedCertificateFactory(org.neo4j.test.ssl.SelfSignedCertificateFactory) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 3 with SelfSignedCertificateFactory

use of org.neo4j.test.ssl.SelfSignedCertificateFactory in project neo4j by neo4j.

the class SslPolicyLoaderTest method setup.

@BeforeEach
void setup() throws Exception {
    home = testDirectory.directory("home");
    baseDir = home.resolve("certificates/default");
    publicCertificateFile = baseDir.resolve("public.crt");
    privateKeyFile = baseDir.resolve("private.key");
    new SelfSignedCertificateFactory().createSelfSignedCertificate(publicCertificateFile, privateKeyFile, "localhost");
    trustedDir = makeDir(baseDir, "trusted");
    FileUtils.copyFile(publicCertificateFile, trustedDir.resolve("public.crt"));
    revokedDir = makeDir(baseDir, "revoked");
}
Also used : SelfSignedCertificateFactory(org.neo4j.test.ssl.SelfSignedCertificateFactory) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with SelfSignedCertificateFactory

use of org.neo4j.test.ssl.SelfSignedCertificateFactory in project neo4j by neo4j.

the class PkiUtilsTest method shouldCreateASelfSignedCertificate.

@Test
void shouldCreateASelfSignedCertificate() throws Exception {
    // Given
    var sslFactory = new SelfSignedCertificateFactory();
    var cPath = testDirectory.homePath().resolve("certificate");
    var pkPath = testDirectory.homePath().resolve("key");
    // When
    sslFactory.createSelfSignedCertificate(cPath, pkPath, "myhost");
    // Then
    // Attempt to load certificate
    var certificates = PkiUtils.loadCertificates(cPath);
    assertThat(certificates.length).isGreaterThan(0);
    // Attempt to load private key
    PrivateKey pk = PkiUtils.loadPrivateKey(pkPath, null);
    assertThat(pk).isNotNull();
}
Also used : PrivateKey(java.security.PrivateKey) SelfSignedCertificateFactory(org.neo4j.test.ssl.SelfSignedCertificateFactory) Test(org.junit.jupiter.api.Test)

Aggregations

SelfSignedCertificateFactory (org.neo4j.test.ssl.SelfSignedCertificateFactory)4 BeforeAll (org.junit.jupiter.api.BeforeAll)2 TransportTestUtil (org.neo4j.bolt.testing.TransportTestUtil)2 PrivateKey (java.security.PrivateKey)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Test (org.junit.jupiter.api.Test)1