use of io.smallrye.graphql.client.vertx.dynamic.VertxDynamicGraphQLClientBuilder in project smallrye-graphql by smallrye.
the class DynamicClientSSLTest method clientAuthentication_badKeystore.
/**
* Server requests client authentication, and the client's certificate is untrusted.
*/
@Test
public void clientAuthentication_badKeystore() throws Exception {
HttpServer server = tools.runServer("classpath:ssl/server.pkcs12.keystore", "serverkeystorepassword", "classpath:ssl/server.pkcs12.truststore", "servertruststorepassword");
try {
System.setProperty("myclient4/mp-graphql/keystore", "classpath:ssl/client.pkcs12.wrong.keystore");
System.setProperty("myclient4/mp-graphql/keystorePassword", "clientwrongkeystorepassword");
System.setProperty("myclient4/mp-graphql/keystoreType", "PKCS12");
WebClientOptions options = new WebClientOptions();
// don't require server auth
options.setTrustAll(true);
DynamicGraphQLClient client = null;
try {
client = new VertxDynamicGraphQLClientBuilder().configKey("myclient4").options(options).url("https://127.0.0.1:" + server.actualPort()).build();
client.executeAsync("asd").await().atMost(Duration.ofSeconds(1));
Assertions.fail("Connection to server should fail");
} catch (Exception e) {
// verify that the server rejected the client's certificate
assertHasCauseContainingMessage(e, "Received fatal alert: bad_certificate");
} finally {
if (client != null) {
client.close();
}
}
} finally {
server.close();
}
}
Aggregations