diff --git a/common/tls/src/main/java/io/helidon/common/tls/TlsUtils.java b/common/tls/src/main/java/io/helidon/common/tls/TlsUtils.java index a3fb19ceb79..dc18a41dd2e 100644 --- a/common/tls/src/main/java/io/helidon/common/tls/TlsUtils.java +++ b/common/tls/src/main/java/io/helidon/common/tls/TlsUtils.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.helidon.nima.common.tls; +package io.helidon.common.tls; import java.security.Principal; import java.security.cert.Certificate; @@ -43,7 +43,7 @@ public static Optional parseCn(Certificate[] certificates) { String[] segments = principal.getName().split("=|,"); while (i + 1 < segments.length) { if ("CN".equals(segments[i])) { - return Optional.of(segments[i+1]); + return Optional.of(segments[i + 1]); } i += 2; } diff --git a/examples/webserver/mutual-tls/src/main/java/io/helidon/examples/webserver/mtls/SecureService.java b/examples/webserver/mutual-tls/src/main/java/io/helidon/examples/webserver/mtls/SecureService.java index df99b480e81..232186f6ba8 100644 --- a/examples/webserver/mutual-tls/src/main/java/io/helidon/examples/webserver/mtls/SecureService.java +++ b/examples/webserver/mutual-tls/src/main/java/io/helidon/examples/webserver/mtls/SecureService.java @@ -15,13 +15,11 @@ */ package io.helidon.examples.webserver.mtls; -import java.security.Principal; - import io.helidon.http.Http; import io.helidon.webserver.http.HttpRules; import io.helidon.webserver.http.HttpService; -import static io.helidon.common.http.Http.HeaderNames.X_HELIDON_CN; +import static io.helidon.http.Http.HeaderNames.X_HELIDON_CN; class SecureService implements HttpService { @Override diff --git a/http/http2/src/test/java/io/helidon/http/http2/Http2HeadersTest.java b/http/http2/src/test/java/io/helidon/http/http2/Http2HeadersTest.java index 883c6b03eb6..2d9e51f6141 100644 --- a/http/http2/src/test/java/io/helidon/http/http2/Http2HeadersTest.java +++ b/http/http2/src/test/java/io/helidon/http/http2/Http2HeadersTest.java @@ -263,6 +263,7 @@ private Http2Headers headers(String hexEncoded, DynamicTable dynamicTable) { return Http2Headers.create(stream, dynamicTable, Http2HuffmanDecoder.create(), + null, new Http2FrameData(header, data)); } } \ No newline at end of file diff --git a/webclient/tests/webclient/src/test/java/io/helidon/webclient/tests/MutualTlsTest.java b/webclient/tests/webclient/src/test/java/io/helidon/webclient/tests/MutualTlsTest.java index f4a93697c22..42aa3fcf164 100644 --- a/webclient/tests/webclient/src/test/java/io/helidon/webclient/tests/MutualTlsTest.java +++ b/webclient/tests/webclient/src/test/java/io/helidon/webclient/tests/MutualTlsTest.java @@ -31,7 +31,7 @@ import org.junit.jupiter.api.Test; -import static io.helidon.common.http.Http.HeaderNames.X_HELIDON_CN; +import static io.helidon.http.Http.HeaderNames.X_HELIDON_CN; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.endsWith; diff --git a/webserver/http2/src/main/java/io/helidon/webserver/http2/Http2Connection.java b/webserver/http2/src/main/java/io/helidon/webserver/http2/Http2Connection.java index 0bea9d871fd..6a71b12fef3 100644 --- a/webserver/http2/src/main/java/io/helidon/webserver/http2/Http2Connection.java +++ b/webserver/http2/src/main/java/io/helidon/webserver/http2/Http2Connection.java @@ -33,6 +33,7 @@ import io.helidon.http.Http; import io.helidon.http.Http.HeaderNames; import io.helidon.http.HttpPrologue; +import io.helidon.http.WritableHeaders; import io.helidon.http.http2.ConnectionFlowControl; import io.helidon.http.http2.Http2ConnectionWriter; import io.helidon.http.http2.Http2ErrorCode; @@ -94,7 +95,6 @@ public class Http2Connection implements ServerConnection, InterruptableTask writableHeaders = WritableHeaders.create(); - ctx.remotePeer().tlsCertificates() - .flatMap(TlsUtils::parseCn) - .ifPresent(cn -> writableHeaders.add(X_HELIDON_CN, cn)); - connectionHeaders = Http2Headers.create(writableHeaders); } private static void settingsUpdate(Http2Config config, Http2Settings.Builder builder) { @@ -596,6 +592,13 @@ private void doHeaders(Semaphore requestSemaphore) { boolean endOfStream; Http2Headers headers; Http2ServerStream stream = streamContext.stream(); + if (connectionHeaders == null) { + WritableHeaders writableHeaders = WritableHeaders.create(); + ctx.remotePeer().tlsCertificates() + .flatMap(TlsUtils::parseCn) + .ifPresent(cn -> writableHeaders.add(X_HELIDON_CN, cn)); + connectionHeaders = Http2Headers.create(writableHeaders); + } if (frameHeader.type() == Http2FrameType.CONTINUATION) { // end of continuations with header frames diff --git a/webserver/webserver/src/main/java/io/helidon/webserver/http1/Http1Connection.java b/webserver/webserver/src/main/java/io/helidon/webserver/http1/Http1Connection.java index d37886d1786..de51e64e044 100644 --- a/webserver/webserver/src/main/java/io/helidon/webserver/http1/Http1Connection.java +++ b/webserver/webserver/src/main/java/io/helidon/webserver/http1/Http1Connection.java @@ -50,7 +50,7 @@ import io.helidon.webserver.http1.spi.Http1Upgrader; import io.helidon.webserver.spi.ServerConnection; -import static io.helidon.common.http.Http.HeaderNames.X_HELIDON_CN; +import static io.helidon.http.Http.HeaderNames.X_HELIDON_CN; import static java.lang.System.Logger.Level.TRACE; import static java.lang.System.Logger.Level.WARNING;