GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — OpenSSL: Allow to obtain used named group via OpenSslSession (#17058) · netty/netty@14a4e6a

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • handler/src
    • main/java/io/netty/handler/ssl
      • ExtendedOpenSslSession.java
      • GroupsConverter.java
      • OpenSslSession.java
      • ReferenceCountedOpenSslEngine.java
    • test/java/io/netty/handler/ssl
      • PkiTestingTlsTest.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎handler/src/main/java/io/netty/handler/ssl/ExtendedOpenSslSession.java‎

Copy file name to clipboardExpand all lines: handler/src/main/java/io/netty/handler/ssl/ExtendedOpenSslSession.java
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,11 @@ public void handshakeFinished(byte[] id, String cipher, String protocol, byte[]
251251
wrapped.handshakeFinished(id, cipher, protocol, peerCertificate, peerCertificateChain, creationTime, timeout);
252252
}
253253

254+
@Override
255+
public String getNamedGroup() {
256+
return wrapped.getNamedGroup();
257+
}
258+
254259
@Override
255260
public boolean equals(Object o) {
256261
return wrapped.equals(o);
Collapse file

‎handler/src/main/java/io/netty/handler/ssl/GroupsConverter.java‎

Copy file name to clipboardExpand all lines: handler/src/main/java/io/netty/handler/ssl/GroupsConverter.java
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ static String toOpenSsl(String key) {
3434
return "P-521";
3535
case "x25519":
3636
return "X25519";
37+
case "x448":
38+
return "X448";
39+
case "x25519mlkem786":
40+
return "X25519MLKEM768";
3741
default:
3842
return key;
3943
}
Collapse file

‎handler/src/main/java/io/netty/handler/ssl/OpenSslSession.java‎

Copy file name to clipboardExpand all lines: handler/src/main/java/io/netty/handler/ssl/OpenSslSession.java
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ public interface OpenSslSession extends SSLSession {
3434
*/
3535
boolean hasPeerCertificates();
3636

37+
/**
38+
* Returns the used named group or {@code null} if none was used or if it can't be determined.
39+
*
40+
* @return the named group
41+
*/
42+
default String getNamedGroup() {
43+
return null;
44+
}
45+
3746
@Override
3847
OpenSslSessionContext getSessionContext();
3948
}
Collapse file

‎handler/src/main/java/io/netty/handler/ssl/ReferenceCountedOpenSslEngine.java‎

Copy file name to clipboardExpand all lines: handler/src/main/java/io/netty/handler/ssl/ReferenceCountedOpenSslEngine.java
+16-1Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2489,6 +2489,7 @@ private final class DefaultOpenSslSession implements OpenSslInternalSession {
24892489
// Updated once a new handshake is started and so the SSLSession reused.
24902490
private long lastAccessed = -1;
24912491

2492+
private volatile String namedGroup;
24922493
private volatile int applicationBufferSize = MAX_PLAINTEXT_LENGTH;
24932494
private volatile Certificate[] localCertificateChain;
24942495
private volatile Map<String, Object> keyValueStorage = new ConcurrentHashMap<String, Object>();
@@ -2653,7 +2654,16 @@ public void handshakeFinished(byte[] id, String cipher, String protocol, byte[]
26532654
}
26542655
this.cipher = toJavaCipherSuite(cipher, protocol);
26552656
this.protocol = protocol;
2656-
2657+
try {
2658+
String groupName = SSL.getGroupName(ssl);
2659+
if (groupName != null) {
2660+
// Normalize group name across BoringSSL/OpenSSL versions.
2661+
groupName = GroupsConverter.toOpenSsl(groupName);
2662+
}
2663+
this.namedGroup = groupName;
2664+
} catch (Exception e) {
2665+
throw new SSLException(e);
2666+
}
26572667
if (clientMode) {
26582668
if (isEmpty(peerCertificateChain)) {
26592669
peerCerts = EmptyArrays.EMPTY_CERTIFICATES;
@@ -2725,6 +2735,11 @@ private void initCerts(byte[][] chain, int startPos) {
27252735
}
27262736
}
27272737

2738+
@Override
2739+
public String getNamedGroup() {
2740+
return namedGroup;
2741+
}
2742+
27282743
@Override
27292744
public Certificate[] getPeerCertificates() throws SSLPeerUnverifiedException {
27302745
synchronized (ReferenceCountedOpenSslEngine.this) {
Collapse file

‎handler/src/test/java/io/netty/handler/ssl/PkiTestingTlsTest.java‎

Copy file name to clipboardExpand all lines: handler/src/test/java/io/netty/handler/ssl/PkiTestingTlsTest.java
+10-2Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
import java.util.stream.Stream;
4646
import javax.net.ssl.SNIHostName;
4747
import javax.net.ssl.SSLParameters;
48+
import javax.net.ssl.SSLSession;
49+
50+
import static org.assertj.core.api.Assertions.assertThat;
4851

4952
public class PkiTestingTlsTest {
5053

@@ -282,6 +285,12 @@ public void userEventTriggered(ChannelHandlerContext ctx, Object evt)
282285
if (evt instanceof SslHandshakeCompletionEvent) {
283286
SslHandshakeCompletionEvent shce = (SslHandshakeCompletionEvent) evt;
284287
if (shce.isSuccess()) {
288+
SSLSession session = handler.engine().getSession();
289+
if (session instanceof OpenSslSession) {
290+
String namedGroup = ((OpenSslSession) handler.engine()
291+
.getSession()).getNamedGroup();
292+
assertThat(OpenSsl.NAMED_GROUPS).contains(namedGroup);
293+
}
285294
promise.setSuccess(shce);
286295
} else {
287296
promise.setFailure(shce.cause());
@@ -292,8 +301,7 @@ public void userEventTriggered(ChannelHandlerContext ctx, Object evt)
292301
}
293302

294303
@Override
295-
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause)
296-
throws Exception {
304+
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
297305
if (!promise.tryFailure(cause)) {
298306
ctx.fireExceptionCaught(cause);
299307
}

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.