Repository navigation
envoy: allowing alt-svc from IPs, fixing HTTP/3 cert bypass - #35551
Conversation
Signed-off-by: Alyssa Wilk <[email protected]>
|
not sure if this will pass CI - I only ran the new test so there may be extra cleanup I need to do. Either way I'd appreciate @fredyw doing a pass of my horrible Java, and @RyanTheOptimist telling me if you think this a valid workaround for the handshake problem (i.e. if I'm not abusing https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/transport_sockets/tls/v3/common.proto#enum-extensions-transport-sockets-tls-v3-certificatevalidationcontext-trustchainverification) |
|
oh and also @RyanTheOptimist let me know if I should split out one or both functional changes. I feel weird doing 2 runtime guards in one PR but they're both so bitty I also didn't want to deluge everyone with PRs |
| "This is a simple text file served by QUIC.\n", | ||
| Collections.emptyMap()); | ||
| // Next set up the HTTP/2 server, advertising HTTP/3 support for the HTTP/3 server | ||
| String alt_svc = "h3=\":" + mHttp3TestServer.getPort() + "\"; ma=86400"; |
There was a problem hiding this comment.
butIWantMySnakeCase! ;-) (fixed)
|
|
||
| // If true, dump envoy logs on test completion. | ||
| // Ideally we could override this from the command line but that's TBD. | ||
| boolean mPrintEnvoyLogs = false; |
| // The log file name, set up if mPrintEnvoyLogs is true. | ||
| private String mLogFilename; | ||
| // The engine for this test. | ||
| CronvoyUrlRequestContext mCronvoyEngine; |
| JniLibrary.loadTestLibrary(); | ||
| } | ||
|
|
||
| public void setUp(boolean setUpLogging) throws Exception { |
There was a problem hiding this comment.
You can add @Before annotation here, so we don't need to explicitly call setup in each test.
There was a problem hiding this comment.
Ah I'd had that before but I thought it might be useful to have the option of turning up debug logging for a single test once we had a bunch. I can put it back if you prefer though
|
|
||
| // Optionally, set up logging. This will slow down the tests a bit but make debugging much | ||
| // easier. | ||
| if (setUpLogging) { |
There was a problem hiding this comment.
Instead of using netlog, there's another way to show Envoy logs via
private CronvoyLogger mLogger = new CronvoyLogger() {
@Override
public void log(int logLevel, String message) {
System.out.print(message);
}
}
There was a problem hiding this comment.
very good call - done
|
|
||
| // Do a request to https://127.0.0.1:test_server_port/ | ||
| TestUrlRequestCallback callback = new TestUrlRequestCallback(); | ||
| String mNewUrl = "https://" + mHttp2TestServer.getAddress() + "/"; |
| // Ideally we could override this from the command line but that's TBD. | ||
| boolean mPrintEnvoyLogs = false; | ||
| // The HTTP/2 server, set up to alt-svc to the HTTP/3 server | ||
| private HttpTestServerFactory.HttpTestServer mHttp2TestServer; |
There was a problem hiding this comment.
optional: In Java, the convention is to use camelCase and not Hungarian notation although there's a lot of existing code in Envoy Mobile that uses Hungarian notation. Since this is a new file, let's use camelCase.
| mCronvoyEngine = new CronvoyUrlRequestContext(nativeCronetEngineBuilder); | ||
|
|
||
| // Do a request to https://127.0.0.1:test_server_port/ | ||
| TestUrlRequestCallback callback = new TestUrlRequestCallback(); |
Signed-off-by: Alyssa Wilk <[email protected]>
alyssawilk
left a comment
There was a problem hiding this comment.
thanks for the review!
|
|
||
| // If true, dump envoy logs on test completion. | ||
| // Ideally we could override this from the command line but that's TBD. | ||
| boolean mPrintEnvoyLogs = false; |
| // Ideally we could override this from the command line but that's TBD. | ||
| boolean mPrintEnvoyLogs = false; | ||
| // The HTTP/2 server, set up to alt-svc to the HTTP/3 server | ||
| private HttpTestServerFactory.HttpTestServer mHttp2TestServer; |
| JniLibrary.loadTestLibrary(); | ||
| } | ||
|
|
||
| public void setUp(boolean setUpLogging) throws Exception { |
There was a problem hiding this comment.
Ah I'd had that before but I thought it might be useful to have the option of turning up debug logging for a single test once we had a bunch. I can put it back if you prefer though
| "This is a simple text file served by QUIC.\n", | ||
| Collections.emptyMap()); | ||
| // Next set up the HTTP/2 server, advertising HTTP/3 support for the HTTP/3 server | ||
| String alt_svc = "h3=\":" + mHttp3TestServer.getPort() + "\"; ma=86400"; |
There was a problem hiding this comment.
butIWantMySnakeCase! ;-) (fixed)
|
|
||
| // Optionally, set up logging. This will slow down the tests a bit but make debugging much | ||
| // easier. | ||
| if (setUpLogging) { |
There was a problem hiding this comment.
very good call - done
| mCronvoyEngine = new CronvoyUrlRequestContext(nativeCronetEngineBuilder); | ||
|
|
||
| // Do a request to https://127.0.0.1:test_server_port/ | ||
| TestUrlRequestCallback callback = new TestUrlRequestCallback(); |
|
|
||
| // Do a request to https://127.0.0.1:test_server_port/ | ||
| TestUrlRequestCallback callback = new TestUrlRequestCallback(); | ||
| String mNewUrl = "https://" + mHttp2TestServer.getAddress() + "/"; |
Signed-off-by: Alyssa Wilk <[email protected]>
RyanTheOptimist
left a comment
There was a problem hiding this comment.
A few small comments on the C++. I'll leave the Java to Fredy! :)
| const std::string hostname_; | ||
| // Leaf cert needs to be retained in case of asynchronous validation. | ||
| std::string leaf_cert_; | ||
| const bool accept_untrusted_; |
There was a problem hiding this comment.
nit: might be worth a comment, perhaps mentioning that this should really only be true in tests?
| public: | ||
| explicit EnvoyQuicProofVerifier(Envoy::Ssl::ClientContextSharedPtr&& context) | ||
| : context_(std::move(context)) { | ||
| explicit EnvoyQuicProofVerifier(Envoy::Ssl::ClientContextSharedPtr&& context, |
There was a problem hiding this comment.
Or alternatively comment here about accept_untrusted?
There was a problem hiding this comment.
yeah I'll point at the docs, which don't mention tests probabably because people do terrible things in prod too =P
| return options->serverNameOverride().value(); | ||
| } | ||
| return std::string(transport_socket_factory.defaultServerNameIndication()); | ||
| std::string transport = std::string(host->transportSocketFactory().defaultServerNameIndication()); |
There was a problem hiding this comment.
nit: should this variable perhaps be named default_sni?
| return std::string(transport_socket_factory.defaultServerNameIndication()); | ||
| std::string transport = std::string(host->transportSocketFactory().defaultServerNameIndication()); | ||
| if (!transport.empty() || | ||
| !Runtime::runtimeFeatureEnabled("envoy.reloadable_features.allow_alt_svc_for_ips")) { |
There was a problem hiding this comment.
IPs are illegal in the TLS SNI extension so if this method were actually returning the SNI, this would be bad. But it seems like that's not really what this method returns. Instead it's returning something like the target hostname? So how 'bout we rename this method to getTargetHostname()? Or something better?
Signed-off-by: Alyssa Wilk <[email protected]>
| !Runtime::runtimeFeatureEnabled("envoy.reloadable_features.allow_alt_svc_for_ips")) { | ||
| return transport; | ||
| } | ||
| return host->hostname(); |
There was a problem hiding this comment.
Is this supposed to be an IP string?
There was a problem hiding this comment.
yeah, otherwise the SNI checks return the hostname
There was a problem hiding this comment.
Can you comment "if there is no configured SNI, try to return IP string as the host name"
| if (!succeeded) { | ||
| error = error_details; | ||
| } else { | ||
| } else if (!accept_untrusted_ || !Runtime::runtimeFeatureEnabled( |
There was a problem hiding this comment.
Why do we need this for E-M test to pass?
There was a problem hiding this comment.
The platform verifier code respects envoy::extensions::transport_sockets::tls::v3::CertificateValidationContext::ACCEPT_UNTRUSTED but the quic proof verifier complains about
49] Client: Closing connection: c145fcaf20ae11af, with wire error: CRYPTO_ERROR(certificate unknown), error: QUIC_TLS_CERTIFICATE_UNKNOWN, and details: TLS handshake failure (ENCRYPTION_HANDSHAKE) 46: certificate unknown
I'd think if I ask to accept untrusted certs I'd accept this unknown cert but it's broken without this change
There was a problem hiding this comment.
Oh, I see. The test uses IP address as the host but the test server sends a test cert for lyft.com. Fair enough!
Signed-off-by: Alyssa Wilk <[email protected]>
|
/retest |
Signed-off-by: Alyssa Wilk <[email protected]>
Signed-off-by: Alyssa Wilk <[email protected]>
Signed-off-by: Alyssa Wilk <[email protected]>
|
/wait on CI |
Signed-off-by: Alyssa Wilk <[email protected]>
Signed-off-by: Alyssa Wilk <[email protected]>
Signed-off-by: Alyssa Wilk <[email protected]>
|
/retest |
…xy#35551) This adds a real HTTP/3 test for Envoy mobile's Cronet APIs. In order for this to work it fixes 2 issues in Envoy, the first that the connection grid didn't do lookups for ip based hostname. The second that ACCEPT_UNTRUSTED didn't fully work for QUIC. Risk Level: low Testing: e2e test Docs Changes: n/a Release Notes: inline [Optional Runtime guard:] guarded both functional changes --------- Signed-off-by: Alyssa Wilk <[email protected]> Signed-off-by: Martin Duke <[email protected]>
…xy#35551) This adds a real HTTP/3 test for Envoy mobile's Cronet APIs. In order for this to work it fixes 2 issues in Envoy, the first that the connection grid didn't do lookups for ip based hostname. The second that ACCEPT_UNTRUSTED didn't fully work for QUIC. Risk Level: low Testing: e2e test Docs Changes: n/a Release Notes: inline [Optional Runtime guard:] guarded both functional changes --------- Signed-off-by: Alyssa Wilk <[email protected]> Signed-off-by: asingh-g <[email protected]>
This adds a real HTTP/3 test for Envoy mobile's Cronet APIs.
In order for this to work it fixes 2 issues in Envoy, the first that the connection grid didn't do lookups for ip based hostname. The second that ACCEPT_UNTRUSTED didn't fully work for QUIC.
Risk Level: low
Testing: e2e test
Docs Changes: n/a
Release Notes: inline
[Optional Runtime guard:] guarded both functional changes