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();
}
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());
}
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();
}
}
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();
}
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;
}
Aggregations