Skip to content

Commit

Permalink
Merged branch 'jetty-12.0.x' into 'jetty-12.1.x'.
Browse files Browse the repository at this point in the history
Signed-off-by: Simone Bordet <[email protected]>
  • Loading branch information
sbordet committed Sep 20, 2024
2 parents acb30ab + 9c34263 commit 838b97d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,8 @@ default boolean isSecure()
interface SslSessionData
{
/**
* The name at which an {@code SslSessionData} instance may be found as a request
* {@link org.eclipse.jetty.util.Attributes Attribute} or from {@link SSLSession#getValue(String)}.
* The name at which an {@code SslSessionData} instance may be found
* as a request {@link org.eclipse.jetty.util.Attributes attribute}.
*/
String ATTRIBUTE = "org.eclipse.jetty.io.Endpoint.SslSessionData";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ public class SslEndPoint extends AbstractEndPoint implements EndPoint.Wrapper

private final Callback _incompleteWriteCallback = new IncompleteWriteCallback();
private Throwable _failure;
private SslSessionData _sslSessionData;

public SslEndPoint()
{
Expand Down Expand Up @@ -1572,6 +1573,28 @@ private Throwable handleException(Throwable x, String context)
}
}

@Override
public SslSessionData getSslSessionData()
{
SSLSession sslSession = _sslEngine.getSession();
SslSessionData sslSessionData = _sslSessionData;
if (sslSessionData == null)
{
String cipherSuite = sslSession.getCipherSuite();

X509Certificate[] peerCertificates = _sslContextFactory != null
? _sslContextFactory.getX509CertChain(sslSession)
: SslContextFactory.getCertChain(sslSession);

byte[] bytes = sslSession.getId();
String idStr = StringUtil.toHexString(bytes);

sslSessionData = SslSessionData.from(sslSession, idStr, cipherSuite, peerCertificates);
_sslSessionData = sslSessionData;
}
return sslSessionData;
}

@Override
public String toString()
{
Expand Down Expand Up @@ -1644,28 +1667,6 @@ public String toString()
return String.format("SSL@%h.DEP.writeCallback", SslConnection.this);
}
}

@Override
public SslSessionData getSslSessionData()
{
SSLSession sslSession = _sslEngine.getSession();
SslSessionData sslSessionData = (SslSessionData)sslSession.getValue(SslSessionData.ATTRIBUTE);
if (sslSessionData == null)
{
String cipherSuite = sslSession.getCipherSuite();

X509Certificate[] peerCertificates = _sslContextFactory != null
? _sslContextFactory.getX509CertChain(sslSession)
: SslContextFactory.getCertChain(sslSession);

byte[] bytes = sslSession.getId();
String idStr = StringUtil.toHexString(bytes);

sslSessionData = SslSessionData.from(sslSession, idStr, cipherSuite, peerCertificates);
sslSession.putValue(SslSessionData.ATTRIBUTE, sslSessionData);
}
return sslSessionData;
}
}

private abstract class RunnableTask implements Invocable.Task
Expand Down

0 comments on commit 838b97d

Please sign in to comment.