Skip to content

Commit

Permalink
review changes
Browse files Browse the repository at this point in the history
Signed-off-by: tvallin <thibault.vallin@oracle.com>
  • Loading branch information
tvallin committed Aug 21, 2023
1 parent fa33ae3 commit 8273603
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions common/tls/src/main/java/io/helidon/common/tls/TlsUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -43,7 +43,7 @@ public static Optional<String> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ private Http2Headers headers(String hexEncoded, DynamicTable dynamicTable) {
return Http2Headers.create(stream,
dynamicTable,
Http2HuffmanDecoder.create(),
null,
new Http2FrameData(header, data));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -94,7 +95,6 @@ public class Http2Connection implements ServerConnection, InterruptableTask<Void
private final Http2Settings serverSettings;
private final boolean sendErrorDetails;
private final ConnectionFlowControl flowControl;
private final Http2Headers connectionHeaders;

// initial client settings, until we receive real ones
private Http2Settings clientSettings = Http2Settings.builder()
Expand All @@ -106,6 +106,7 @@ public class Http2Connection implements ServerConnection, InterruptableTask<Void
private HttpPrologue upgradePrologue;
private Http2Headers upgradeHeaders;
private State state = State.WRITE_SERVER_SETTINGS;
private Http2Headers connectionHeaders;
private int continuationExpectedStreamId;
private int lastStreamId;
private long maxClientConcurrentStreams;
Expand Down Expand Up @@ -139,11 +140,6 @@ public class Http2Connection implements ServerConnection, InterruptableTask<Void
.maxFrameSize(http2Config.maxFrameSize())
.build();
this.lastRequestTimestamp = Http.DateTime.timestamp();
WritableHeaders<?> 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) {
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 8273603

Please sign in to comment.