Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an example of using Dropwizard with Conscrypt
Conscrypt is used as the JCE provider for a HTTP/2 app.
- Loading branch information
Showing
8 changed files
with
131 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
dropwizard-http2/src/test/java/io/dropwizard/http2/Http2WithConscrypt.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,42 @@ | |||
package io.dropwizard.http2; | |||
|
|||
import io.dropwizard.Configuration; | |||
import io.dropwizard.testing.junit.DropwizardAppRule; | |||
import org.conscrypt.OpenSSLProvider; | |||
import org.eclipse.jetty.client.HttpClient; | |||
import org.eclipse.jetty.http2.client.HTTP2Client; | |||
import org.eclipse.jetty.http2.client.http.HttpClientTransportOverHTTP2; | |||
import org.eclipse.jetty.util.ssl.SslContextFactory; | |||
import org.junit.After; | |||
import org.junit.Before; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
|
|||
import java.security.Security; | |||
import java.util.Optional; | |||
|
|||
import static io.dropwizard.testing.ConfigOverride.config; | |||
import static io.dropwizard.testing.ResourceHelpers.resourceFilePath; | |||
|
|||
public class Http2WithConscrypt extends AbstractHttp2Test { | |||
|
|||
static { | |||
Security.addProvider(new OpenSSLProvider()); | |||
} | |||
|
|||
private static final String PREFIX = "tls_conscrypt"; | |||
|
|||
@Rule | |||
public final DropwizardAppRule<Configuration> appRule = new DropwizardAppRule<>( | |||
FakeApplication.class, resourceFilePath("test-http2-with-conscrypt.yml"), | |||
Optional.of(PREFIX), | |||
config(PREFIX, "server.connector.keyStorePath", resourceFilePath("stores/http2_server.jks")), | |||
config(PREFIX, "server.connector.trustStorePath", resourceFilePath("stores/http2_client.jts")) | |||
); | |||
|
|||
@Test | |||
public void testHttp2WithCustomCipher() throws Exception { | |||
assertResponse(client.GET("https://localhost:" + appRule.getLocalPort() + "/api/test")); | |||
} | |||
|
|||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
dropwizard-http2/src/test/resources/test-http2-with-conscrypt.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,11 @@ | |||
server: | |||
type: simple | |||
connector: | |||
type: h2 | |||
port: 0 | |||
keyStorePassword: http2_server | |||
trustStorePassword: http2_client | |||
validateCerts: false | |||
jceProvider: Conscrypt | |||
applicationContextPath: /api | |||
adminContextPath: /admin |