Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldLoadPEMPrivateKey() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldLoadPEMPrivateKey()
        {
            // Given
            SelfSignedCertificate cert = new SelfSignedCertificate("example.com");
            PkiUtils certs             = new PkiUtils();

            File privateKey = cert.privateKey();

            // When
            PrivateKey pk = certs.LoadPrivateKey(privateKey);

            // Then
            assertNotNull(pk);
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldLoadPEMCertificates() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldLoadPEMCertificates()
        {
            // Given
            SelfSignedCertificate cert = new SelfSignedCertificate("example.com");
            PkiUtils certs             = new PkiUtils();

            File pemCertificate = cert.certificate();

            // When
            Certificate[] certificates = certs.LoadCertificates(pemCertificate);

            // Then
            assertThat(certificates.Length, equalTo(1));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// For backwards-compatibility reasons, we support both PEM-encoded private keys *and* raw binary files containing
        /// the private key data
        /// </summary>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldLoadBinaryPrivateKey() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldLoadBinaryPrivateKey()
        {
            // Given
            SelfSignedCertificate cert = new SelfSignedCertificate("example.com");
            PkiUtils certs             = new PkiUtils();

            File keyFile = _testDirectory.file("certificate");

            assertTrue(keyFile.createNewFile());
            sbyte[] raw = certs.LoadPrivateKey(cert.privateKey()).Encoded;

            using (FileChannel ch = FileChannel.open(keyFile.toPath(), WRITE))
            {
                FileUtils.writeAll(ch, ByteBuffer.wrap(raw));
            }

            // When
            PrivateKey pk = certs.LoadPrivateKey(keyFile);

            // Then
            assertNotNull(pk);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// For backwards-compatibility reasons, we support both PEM-encoded certificates *and* raw binary files containing
        /// the certificate data.
        /// </summary>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldLoadBinaryCertificates() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldLoadBinaryCertificates()
        {
            // Given
            SelfSignedCertificate cert = new SelfSignedCertificate("example.com");
            PkiUtils certs             = new PkiUtils();

            File cPath = _testDirectory.file("certificate");

            assertTrue(cPath.createNewFile());
            sbyte[] raw = certs.LoadCertificates(cert.certificate())[0].Encoded;

            using (FileChannel ch = FileChannel.open(cPath.toPath(), WRITE))
            {
                FileUtils.writeAll(ch, ByteBuffer.wrap(raw));
            }

            // When
            Certificate[] certificates = certs.LoadCertificates(cPath);

            // Then
            assertThat(certificates.Length, equalTo(1));
        }