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 — Netty SSLHandler.isEncrypted mistakes SNMP as encrypted · Issue #14238 · netty/netty

Netty SSLHandler.isEncrypted mistakes SNMP as encrypted #14238

New issue
Copy link
New issue
Copy link
Closed
#14243
Closed
Netty SSLHandler.isEncrypted mistakes SNMP as encrypted#14238
#14243
Copy link
Milestone
4.1.113.Final

Description

@elise700
elise700
opened on Aug 18, 2024
Issue body actions

I am trying to determine if a SNMP packet is TLS or plain text TCP and have a trap packet that starts with these bytes: 30 82 0c 48 02 01 01 04

Expected behavior

SSLHandler.isEncrypted should return false as trap is not encrypted

Actual behavior

It returns true. This is because the getEncryptedPacketLength() method returns what it calculated as the packetLength.
Initially the packet is identified as not tls because the first byte is not an SSL_CONTENT_TYPE.
Later on in the if (!tls) stanza the following variables are set.
headerLength = 3
majorVersion = 2
packetLength=12422

And because the packetLength <= headerLength, the packetLength is returned rather then NOT_ENCRYPTED. A possible solution would be to add an optional parameter to specify if checking for SSLv2 is disabled.

If you assume that the incoming TCP stream cannot be SSLv2 and omit this check then the method returns NOT_ENCRYPTED as desired.

Steps to reproduce

Create a ByteBuf with the above bytes and call SSLHanlder.isEncypted()

Minimal yet complete reproducer code (or URL to code)

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.handler.ssl.SslHandler;

public class ShortTest {

public static void main(String[] args) {
	
	ByteBuf buf = Unpooled.buffer();

	byte[] data = new byte[] {0x30, (byte)0x82, 0x0c, 0x48, 0x02, 0x01, 0x01, 0x01};
	buf.writeBytes(data);
	
	if (SslHandler.isEncrypted(buf)) {
		System.out.println("data is ssl or tls");
	} else {
		System.out.println("data is not ssl or tls");
	}
}

}### Netty version
Version 4.1.109

JVM version (e.g. java -version)

openjdk version "1.8.0_412"
OpenJDK Runtime Environment (build 1.8.0_412-b08)
OpenJDK 64-Bit Server VM (build 25.412-b08, mixed mode)

OS version (e.g. uname -a)

[14:35:06 elise@joy3 bin]$ uname -a
Linux joy3.tavve.com 3.10.0-327.36.2.el7.x86_64 #1 SMP Mon Oct 10 23:08:37 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Activity

  1. normanmaurer
    added a commit that references this issue on Aug 21, 2024

    Add new SslHandler.isEncrypted(...) variant that will not produce fal…

    e93e668
  2. chrisvest commented on Aug 21, 2024

    @chrisvest
    chrisvest
    on Aug 21, 2024
    Member
    More actions

    @elise700 Are you running into this because you're using OptionalSslHandler, or how is SslHandler.isEncrypted being called?

  3. elise700 commented on Aug 22, 2024

    @elise700
    elise700
    on Aug 22, 2024 via email
    Author
    More actions
    I was following the PortUnification example code so I could open a port and accept clients using either TCP plaintext or TLS. The method SSLHandler.isEncrypted is called. I am not using the OptionalSslHandler but I am open to changing my approach if that is the preferred way to handle this. Thanks, Elise
    …
    On Wed, Aug 21, 2024 at 1:38 PM Chris Vest ***@***.***> wrote: @elise700 <https://github.com/elise700> Are you running into this because you're using OptionalSslHandler, or how is SslHandler.isEncrypted being called? — Reply to this email directly, view it on GitHub <#14238 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AC4USEI35H5MZ7A3YOHBX63ZSTF7ZAVCNFSM6AAAAABMWSTKXWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBSGYZDGNJZHA> . You are receiving this because you were mentioned.Message ID: ***@***.***>
  4. normanmaurer
    closed this as completedin dc30c33on Aug 23, 2024
  5. normanmaurer
    added this to the 4.1.113.Final milestone on Aug 23, 2024
  6. normanmaurer
    added 2 commits that reference this issue on Aug 23, 2024

    Add new SslHandler.isEncrypted(...) variant that will not produce fal… (

    b3c24e2

    Add new SslHandler.isEncrypted(...) variant that will not produce fal… (

    9255bba
  7. Clownsw
    added a commit that references this issue on Aug 23, 2024

    Add new SslHandler.isEncrypted(...) variant that will not produce fal… (

    dc30c33
  8. AlohaWorld
    added a commit that references this issue on Mar 1, 2026

    Add new SslHandler.isEncrypted(...) variant that will not produce fal…

    04c3d44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      • 4.1.113.Final

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      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.