Search in sources :

Example 1 with KeychainX509KeyManager

use of ch.cyberduck.core.ssl.KeychainX509KeyManager in project cyberduck by iterate-ch.

the class DAVSessionTest method testRedirectHttpsAlert.

@Test
@Ignore
public void testRedirectHttpsAlert() throws Exception {
    final Host host = new Host(new DAVProtocol(), "svn.cyberduck.io");
    final AtomicBoolean warning = new AtomicBoolean();
    final DAVSession session = new DAVSession(host, new DefaultX509TrustManager(), new KeychainX509KeyManager(new DisabledCertificateIdentityCallback(), host, new DisabledCertificateStore())) {
    };
    final LoginConnectionService c = new LoginConnectionService(new DisabledLoginCallback() {

        @Override
        public void warn(final Host bookmark, final String title, final String message, final String continueButton, final String disconnectButton, final String preference) {
            assertEquals("Unsecured WebDAV (HTTP) connection", title);
            assertEquals("connection.unsecure.svn.cyberduck.io", preference);
            warning.set(true);
        }
    }, new DisabledHostKeyCallback(), new DisabledPasswordStore(), new DisabledProgressListener());
    c.connect(session, new DisabledCancelCallback());
    assertTrue(warning.get());
    session.close();
}
Also used : KeychainX509KeyManager(ch.cyberduck.core.ssl.KeychainX509KeyManager) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) DefaultX509TrustManager(ch.cyberduck.core.ssl.DefaultX509TrustManager) Ignore(org.junit.Ignore) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 2 with KeychainX509KeyManager

use of ch.cyberduck.core.ssl.KeychainX509KeyManager in project cyberduck by iterate-ch.

the class DAVSessionTest method testMutualTlsUnknownCA.

@Test(expected = SSLNegotiateException.class)
@Ignore
public void testMutualTlsUnknownCA() throws Exception {
    final Host host = new Host(new DAVSSLProtocol(), "auth.startssl.com");
    final DAVSession session = new DAVSession(host, new DefaultX509TrustManager(), new KeychainX509KeyManager(new DisabledCertificateIdentityCallback(), host, new DisabledCertificateStore() {

        @Override
        public X509Certificate choose(final CertificateIdentityCallback prompt, final String[] keyTypes, final Principal[] issuers, final Host bookmark) throws ConnectionCanceledException {
            assertEquals("auth.startssl.com", bookmark.getHostname());
            assertTrue(Arrays.asList(issuers).contains(new X500Principal("" + "CN=StartCom Certification Authority, OU=Secure Digital Certificate Signing, O=StartCom Ltd., C=IL")));
            assertTrue(Arrays.asList(issuers).contains(new X500Principal("" + "CN=StartCom Class 1 Primary Intermediate Client CA, OU=Secure Digital Certificate Signing, O=StartCom Ltd., C=IL")));
            assertTrue(Arrays.asList(issuers).contains(new X500Principal("" + "CN=StartCom Class 2 Primary Intermediate Client CA, OU=Secure Digital Certificate Signing, O=StartCom Ltd., C=IL")));
            assertTrue(Arrays.asList(issuers).contains(new X500Principal("" + "CN=StartCom Class 3 Primary Intermediate Client CA, OU=Secure Digital Certificate Signing, O=StartCom Ltd., C=IL")));
            throw new ConnectionCanceledException();
        }
    }));
    final LoginConnectionService c = new LoginConnectionService(new DisabledLoginCallback() {

        @Override
        public Credentials prompt(final Host bookmark, String username, String title, String reason, LoginOptions options) {
            // 
            return new Credentials();
        }
    }, new DisabledHostKeyCallback(), new DisabledPasswordStore(), new DisabledProgressListener());
    c.connect(session, new DisabledCancelCallback());
}
Also used : ConnectionCanceledException(ch.cyberduck.core.exception.ConnectionCanceledException) KeychainX509KeyManager(ch.cyberduck.core.ssl.KeychainX509KeyManager) X500Principal(javax.security.auth.x500.X500Principal) DefaultX509TrustManager(ch.cyberduck.core.ssl.DefaultX509TrustManager) Ignore(org.junit.Ignore) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 3 with KeychainX509KeyManager

use of ch.cyberduck.core.ssl.KeychainX509KeyManager in project cyberduck by iterate-ch.

the class DAVSessionTest method testConnectProxyHttps.

@Test
@Ignore
public void testConnectProxyHttps() throws Throwable {
    final Host host = new Host(new DAVSSLProtocol(), "svn.cyberduck.io");
    final AtomicBoolean verified = new AtomicBoolean();
    final DAVSession session = new DAVSession(host, new DefaultX509TrustManager() {

        @Override
        public void verify(final String hostname, final X509Certificate[] certs, final String cipher) throws CertificateException {
            assertNotNull(hostname);
            verified.set(true);
            super.verify(hostname, certs, cipher);
        }
    }, new KeychainX509KeyManager(new DisabledCertificateIdentityCallback(), host, new DisabledCertificateStore())) {
    };
    final LoginConnectionService c = new LoginConnectionService(new DisabledLoginCallback() {

        @Override
        public Credentials prompt(final Host bookmark, final String username, final String title, final String reason, final LoginOptions options) {
            return new Credentials("test", "test");
        }
    }, new DisabledHostKeyCallback(), new DisabledPasswordStore(), new DisabledProgressListener(), new ProxyFinder() {

        @Override
        public Proxy find(final String target) {
            return new Proxy(Proxy.Type.HTTPS, "localhost", 8080);
        }
    });
    try {
        Executors.newSingleThreadExecutor().submit(new Callable<Void>() {

            @Override
            public Void call() throws Exception {
                c.connect(session, new DisabledCancelCallback());
                return null;
            }
        }).get();
    } catch (ExecutionException e) {
        throw e.getCause();
    } finally {
        assertTrue(verified.get());
        session.close();
    }
}
Also used : KeychainX509KeyManager(ch.cyberduck.core.ssl.KeychainX509KeyManager) CertificateException(java.security.cert.CertificateException) Callable(java.util.concurrent.Callable) Proxy(ch.cyberduck.core.proxy.Proxy) ExecutionException(java.util.concurrent.ExecutionException) X509Certificate(java.security.cert.X509Certificate) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ProxyFinder(ch.cyberduck.core.proxy.ProxyFinder) DefaultX509TrustManager(ch.cyberduck.core.ssl.DefaultX509TrustManager) Ignore(org.junit.Ignore) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 4 with KeychainX509KeyManager

use of ch.cyberduck.core.ssl.KeychainX509KeyManager in project cyberduck by iterate-ch.

the class DAVSessionTest method testConnectProxyInvalidCredentials.

@Ignore
@Test(expected = ProxyLoginFailureException.class)
public void testConnectProxyInvalidCredentials() throws Exception {
    final Host host = new Host(new DAVSSLProtocol(), "svn.cyberduck.io");
    final DAVSession session = new DAVSession(host, new DefaultX509TrustManager(), new KeychainX509KeyManager(new DisabledCertificateIdentityCallback(), host, new DisabledCertificateStore())) {
    };
    final LoginConnectionService c = new LoginConnectionService(new DisabledLoginCallback() {

        @Override
        public Credentials prompt(final Host bookmark, final String username, final String title, final String reason, final LoginOptions options) {
            return new Credentials("test", "n");
        }
    }, new DisabledHostKeyCallback(), new DisabledPasswordStore(), new DisabledProgressListener(), new ProxyFinder() {

        @Override
        public Proxy find(final String target) {
            return new Proxy(Proxy.Type.HTTP, "localhost", 3128);
        }
    });
    c.connect(session, new DisabledCancelCallback());
    session.close();
}
Also used : KeychainX509KeyManager(ch.cyberduck.core.ssl.KeychainX509KeyManager) ProxyFinder(ch.cyberduck.core.proxy.ProxyFinder) Proxy(ch.cyberduck.core.proxy.Proxy) DefaultX509TrustManager(ch.cyberduck.core.ssl.DefaultX509TrustManager) Ignore(org.junit.Ignore) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 5 with KeychainX509KeyManager

use of ch.cyberduck.core.ssl.KeychainX509KeyManager in project cyberduck by iterate-ch.

the class DefaultCertificateStore method choose.

@Override
public X509Certificate choose(final CertificateIdentityCallback prompt, final String[] keyTypes, final Principal[] issuers, final Host bookmark) throws ConnectionCanceledException {
    final CertificateStoreX509KeyManager store = new KeychainX509KeyManager(prompt, bookmark, this).init();
    final String[] aliases = store.getClientAliases(keyTypes, issuers);
    if (null == aliases) {
        throw new ConnectionCanceledException(String.format("No certificate matching issuer %s found", Arrays.toString(issuers)));
    }
    for (String alias : aliases) {
        return store.getCertificate(alias, keyTypes, issuers);
    }
    return null;
}
Also used : ConnectionCanceledException(ch.cyberduck.core.exception.ConnectionCanceledException) KeychainX509KeyManager(ch.cyberduck.core.ssl.KeychainX509KeyManager) CertificateStoreX509KeyManager(ch.cyberduck.core.ssl.CertificateStoreX509KeyManager)

Aggregations

KeychainX509KeyManager (ch.cyberduck.core.ssl.KeychainX509KeyManager)16 IntegrationTest (ch.cyberduck.test.IntegrationTest)10 Test (org.junit.Test)10 DefaultX509TrustManager (ch.cyberduck.core.ssl.DefaultX509TrustManager)9 Ignore (org.junit.Ignore)7 Proxy (ch.cyberduck.core.proxy.Proxy)5 ProxyFinder (ch.cyberduck.core.proxy.ProxyFinder)5 DefaultTrustManagerHostnameCallback (ch.cyberduck.core.ssl.DefaultTrustManagerHostnameCallback)5 KeychainX509TrustManager (ch.cyberduck.core.ssl.KeychainX509TrustManager)5 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)5 ConnectionCanceledException (ch.cyberduck.core.exception.ConnectionCanceledException)4 X509Certificate (java.security.cert.X509Certificate)4 DisabledCertificateIdentityCallback (ch.cyberduck.core.DisabledCertificateIdentityCallback)3 DisabledCertificateTrustCallback (ch.cyberduck.core.DisabledCertificateTrustCallback)3 CertificateException (java.security.cert.CertificateException)3 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)2 DisabledTranscriptListener (ch.cyberduck.core.DisabledTranscriptListener)2 HttpConnectionPoolBuilder (ch.cyberduck.core.http.HttpConnectionPoolBuilder)2 ProxyHostUrlProvider (ch.cyberduck.core.proxy.ProxyHostUrlProvider)2 CertificateStoreX509KeyManager (ch.cyberduck.core.ssl.CertificateStoreX509KeyManager)2