use of com.yahoo.athenz.instance.provider.ProviderHostnameVerifier in project athenz by yahoo.
the class InstanceHttpProvider method initialize.
@Override
public void initialize(String provider, String providerEndpoint, KeyStore keyStore) {
ProviderHostnameVerifier hostnameVerifier = new ProviderHostnameVerifier(provider);
int readTimeout = Integer.parseInt(System.getProperty(PROP_READ_TIMEOUT, "30000"));
int connectTimeout = Integer.parseInt(System.getProperty(PROP_CONNECT_TIMEOUT, "30000"));
client = new InstanceProviderClient(providerEndpoint, hostnameVerifier, connectTimeout, readTimeout);
}
use of com.yahoo.athenz.instance.provider.ProviderHostnameVerifier in project athenz by yahoo.
the class ProviderHostnameVerifierTest method testHostnameVerifier.
@Test
public void testHostnameVerifier() throws IOException {
SSLSession session = Mockito.mock(SSLSession.class);
Path path = Paths.get("src/test/resources/athenz.instanceid.pem");
String pem = new String(Files.readAllBytes(path));
X509Certificate cert = Crypto.loadX509Certificate(pem);
Certificate[] certs = new Certificate[1];
certs[0] = cert;
Mockito.when(session.getPeerCertificates()).thenReturn(certs);
ProviderHostnameVerifier verifier1 = new ProviderHostnameVerifier("athenz.production");
assertTrue(verifier1.verify("athenz", session));
ProviderHostnameVerifier verifier2 = new ProviderHostnameVerifier("athenz.production2");
assertFalse(verifier2.verify("athenz", session));
}
use of com.yahoo.athenz.instance.provider.ProviderHostnameVerifier in project athenz by yahoo.
the class ProviderHostnameVerifierTest method testHostnameVerifierNullCerts.
@Test
public void testHostnameVerifierNullCerts() throws IOException {
SSLSession session = Mockito.mock(SSLSession.class);
Mockito.when(session.getPeerCertificates()).thenReturn(null);
ProviderHostnameVerifier verifier1 = new ProviderHostnameVerifier("athenz.production");
assertFalse(verifier1.verify("athenz", session));
}
Aggregations