Skip to content

Commit

Permalink
[UNDERTOW-2033] Derrive SecurePredicate from connection encryption, r…
Browse files Browse the repository at this point in the history
…ather than scheme
  • Loading branch information
baranowb committed Apr 26, 2024
1 parent a41521a commit 13a5b3c
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@
package io.undertow.predicate;

import io.undertow.server.HttpServerExchange;
import io.undertow.server.SSLSessionInfo;

import java.util.Collections;
import java.util.Map;
import java.util.Set;

import javax.net.ssl.SSLSession;

/**
* @author Stuart Douglas
*/
Expand All @@ -33,7 +36,10 @@ public class SecurePredicate implements Predicate {

@Override
public boolean resolve(HttpServerExchange value) {
return value.getRequestScheme().equals("https");
final SSLSession session = value.getConnection().getSslSession();
final SSLSessionInfo info = value.getConnection().getSslSessionInfo();
return (session != null && session.isValid())
|| (info != null && info.getSSLSession() != null && info.getSSLSession().isValid());
}

public String toString() {
Expand Down

0 comments on commit 13a5b3c

Please sign in to comment.