newrelic / newrelic-java-agent

The New Relic Java agent
Apache License 2.0
202 stars 144 forks source link

HTTP/2 support in AITs #2111

Open jtduffy opened 4 weeks ago

jtduffy commented 4 weeks ago

Evaluate the existing AITs and see which ones would be candidates for adding coverage for HTTP/2 support.

List of HTTP/2 client and server frameworks: https://docs.google.com/spreadsheets/d/150ntwH2aO9Sr6mg0lVVkNScmLKSJpxNZXhqAoTHKo5U/edit?gid=0#gid=0

Enable HTTPS and HTTP/2 for Spring Boot 3 / Spring Framework 6 Apps

Generate a self signed localhost cert: -keystore keystore.p12 -storetype PKCS12 -storepass password -validity 9999

This will create the keystore keystore.p12 in the current folder. Copy this file into the src/main/resources folder of the application.

Update the application.properties or application.yml file to reference the keystore:

server.port=8443
server.http2.enabled=true
server.ssl.key-alias=localhost
server.ssl.key-store=classpath:keystore.p12
server.ssl.key-store-password=password
server.ssl.key-store-type=PKCS12
server:
  port: 8443
  http2:
    enabled:true
  ssl:
    key-store: classpath:keystore.p12
    key-store-password: password
    key-store-type: PKCS12
    key-alias: localhost

This will start the app with HTTPS and HTTP/2 support listening on port 8443.

workato-integration[bot] commented 4 weeks ago

https://new-relic.atlassian.net/browse/NR-334579

jasonjkeller commented 4 weeks ago

Here's the PR that added an HTTP/2 compatible client to the AITs and documents a few setup steps: https://github.com/newrelic/java-agent-integration-tests/pull/257

By default, when creating the http client I set verify=False so that it won't be a huge hassle to manage certs with HTTP/2.

httpx.Client(http2=True, follow_redirects=True, verify=False)

verify - (optional) SSL certificates (a.k.a CA bundle) used to verify the identity of requested hosts. Either True (default CA bundle), a path to an SSL certificate file, an ssl.SSLContext, or False (which will disable verification).