mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
chore(tls): pin the certificate path against backslash mangling (#3336)
The sibling Azure emulator lost TLS startup on Windows: a path such as D:\Dev\floci\data\tls\cert.crt reached the HTTP server as D:Devflocidatatlscert.crt and died with NoSuchFileException. That is not general SmallRye behaviour, which is what makes it easy to reintroduce. Expression handling leaves a value with no '$' untouched and deliberately compiles without escape processing; the damage comes from StringUtil.split, reached only by the converter for collection-typed properties, which consumes every backslash. So the property's declared type is the entire defence. This emitter is safe today only because it writes quarkus.tls.key-store.pem.0.cert, a scalar Path. The key it wrote before the TLS registry migration, quarkus.http.ssl.certificate.files, is an Optional<List<Path>> and is mangled. Nothing recorded that distinction, so moving back to a plural key would silently break Windows again. Adds tests that assert a Windows-shaped path round-trips through a scalar property, demonstrate the mangling on the collection path so the reasoning is evidence rather than assertion, and fail if the collection-typed keys are ever emitted again. Also hoists the internal HTTP and HTTPS port literals into constants on TlsConfigSource. TlsProxyServer routes to those ports and had its own independent copies, so the two could drift apart silently.
This commit is contained in:
1 parent
278d9ec83e
commit
8a4c6494ed
3 files changed
+137
-4
No files matched your search
@@ -45,6 +45,14 @@ public class TlsConfigSource implements ConfigSource {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(TlsConfigSource.class);
|
||||
|
||||
/**
|
||||
* Internal ports Quarkus binds when TLS is enabled. {@link TlsProxyServer} listens on the
|
||||
* public Floci port and routes to these by protocol, so the two classes must agree; they are
|
||||
* declared here, next to the properties that set them, and referenced from the proxy.
|
||||
*/
|
||||
static final int HTTP_INTERNAL_PORT = 4510;
|
||||
static final int HTTPS_INTERNAL_PORT = 4511;
|
||||
|
||||
private static final String SERVER_CERT_NAME = "floci-server.crt";
|
||||
private static final String SERVER_KEY_NAME = "floci-server.key";
|
||||
private static final String SERVER_METADATA_NAME = "floci-server.metadata.json";
|
||||
@@ -136,8 +144,8 @@ public class TlsConfigSource implements ConfigSource {
|
||||
// and does protocol detection to route HTTP and HTTPS to the correct backend.
|
||||
properties.put("quarkus.http.insecure-requests", "enabled");
|
||||
properties.put("quarkus.http.host", "127.0.0.1");
|
||||
properties.put("quarkus.http.port", "4510");
|
||||
properties.put("quarkus.http.ssl-port", "4511");
|
||||
properties.put("quarkus.http.port", String.valueOf(HTTP_INTERNAL_PORT));
|
||||
properties.put("quarkus.http.ssl-port", String.valueOf(HTTPS_INTERNAL_PORT));
|
||||
|
||||
LOG.infov("TLS: HTTPS enabled, proxy will listen on port {0} (HTTP+HTTPS), cert={1}",
|
||||
resolveProperty("floci.port", "4566"), certPath);
|
||||
|
||||
@@ -51,8 +51,8 @@ public class TlsProxyServer {
|
||||
/** TLS record content type for Handshake (ClientHello). */
|
||||
private static final byte TLS_HANDSHAKE = 0x16;
|
||||
|
||||
private static final int HTTP_BACKEND_PORT = 4510;
|
||||
private static final int HTTPS_BACKEND_PORT = 4511;
|
||||
private static final int HTTP_BACKEND_PORT = TlsConfigSource.HTTP_INTERNAL_PORT;
|
||||
private static final int HTTPS_BACKEND_PORT = TlsConfigSource.HTTPS_INTERNAL_PORT;
|
||||
|
||||
private final Vertx vertx;
|
||||
private final EmulatorConfig config;
|
||||
|
||||
Reference in new issue
Block a user