Top Description Inners Fields Constructors Methods
io.undertow.protocols.ssl

pack-priv final Class SNISSLExplorer

extends Object
Class Inheritance
Imports
java.nio.ByteBuffer, .BufferUnderflowException, java.io.IOException, javax.net.ssl.SNIHostName, .SNIServerName, .SSLException, .StandardConstants, java.nio.charset.StandardCharsets, java.util.ArrayList, .Collections, .LinkedHashMap, .List, .Map, io.undertow.UndertowMessages

Instances of this class acts as an explorer of the network data of an SSL/TLS connection.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv static class

Field Summary

Modifier and TypeField and Description
public static final int
RECORD_HEADER_SIZE

The header size of TLS/SSL records.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static List<SNIServerName>

Returns:

the explored capabilities of the SSL/TLS connection
explore
(ByteBuffer
a ByteBuffer containing inbound or outbound network data for an SSL/TLS connection.
source
)

Launch and explore the security capabilities from byte buffer.

public static List<SNIServerName>

Returns:

the explored capabilities of the SSL/TLS connection
explore
(byte[]
a byte array containing inbound or outbound network data for an SSL/TLS connection.
source
,
int
the start offset in array source at which the network data is read from.
offset
,
int
the maximum number of bytes to read.
length
)

Launch and explore the security capabilities from byte array.

private static List<String>
exploreALPN(ByteBuffer input, int extLen)

private static List<SNIServerName>
exploreClientHello(ByteBuffer input, byte recordMajorVersion, byte recordMinorVersion)

private static SNISSLExplorer.ExtensionInfo
private static List<SNIServerName>
exploreHandshake(ByteBuffer input, byte recordMajorVersion, byte recordMinorVersion, int recordLength)

private static List<SNIServerName>
exploreSNIExt(ByteBuffer input, int extLen)

private static List<SNIServerName>
exploreTLSRecord(ByteBuffer input, byte firstByte, byte secondByte, byte thirdByte)

private static int
private static int
private static int
public static int

Returns:

the required size in byte to explore an SSL/TLS connection
getRequiredSize
(ByteBuffer
a ByteBuffer containing inbound or outbound network data for an SSL/TLS connection.
source
)

Returns the required number of bytes in the source ByteBuffer necessary to explore SSL/TLS connection.

public static int

Returns:

the required size in byte to explore an SSL/TLS connection
getRequiredSize
(byte[]
a byte array containing inbound or outbound network data for an SSL/TLS connection.
source
,
int
the start offset in array source at which the network data is read from.
offset
,
int
the maximum number of bytes to read.
length
)

Returns the required number of bytes in the source byte array necessary to explore SSL/TLS connection.

private static void
ignoreByteVector(ByteBuffer input, int length)

private static void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

RECORD_HEADER_SIZEback to summary
public static final int RECORD_HEADER_SIZE

The header size of TLS/SSL records.

The value of this constant is 5.

Constructor Detail

SNISSLExplorerback to summary
private SNISSLExplorer()

Method Detail

exploreback to summary
public static List<SNIServerName> explore(ByteBuffer source) throws SSLException

Launch and explore the security capabilities from byte buffer.

This method tries to parse as few records as possible from source byte buffer to get the capabilities of an SSL/TLS connection.

Please NOTE that this method must be called before any handshaking occurs. The behavior of this method is not defined in this release if the handshake has begun, or has completed.

This method accesses the source parameter in read-only mode, and does not update the buffer's properties such as capacity, limit, position, and mark values.

Parameters
source:ByteBuffer

a ByteBuffer containing inbound or outbound network data for an SSL/TLS connection.

Returns:List<SNIServerName>

the explored capabilities of the SSL/TLS connection

Exceptions
IOException:
on network data error
BufferUnderflowException:
if not enough source bytes available to make a complete exploration.
exploreback to summary
public static List<SNIServerName> explore(byte[] source, int offset, int length) throws IOException

Launch and explore the security capabilities from byte array.

Please NOTE that this method must be called before any handshaking occurs. The behavior of this method is not defined in this release if the handshake has begun, or has completed. Once handshake has begun, or has completed, the security capabilities can not and should not be launched with this method.

Parameters
source:byte[]

a byte array containing inbound or outbound network data for an SSL/TLS connection.

offset:int

the start offset in array source at which the network data is read from.

length:int

the maximum number of bytes to read.

Returns:List<SNIServerName>

the explored capabilities of the SSL/TLS connection

Exceptions
IOException:
on network data error
BufferUnderflowException:
if not enough source bytes available to make a complete exploration.
See Also
explore(ByteBuffer)
exploreALPNback to summary
private static List<String> exploreALPN(ByteBuffer input, int extLen) throws SSLException
exploreClientHelloback to summary
private static List<SNIServerName> exploreClientHello(ByteBuffer input, byte recordMajorVersion, byte recordMinorVersion) throws SSLException
exploreExtensionsback to summary
private static SNISSLExplorer.ExtensionInfo exploreExtensions(ByteBuffer input) throws SSLException
exploreHandshakeback to summary
private static List<SNIServerName> exploreHandshake(ByteBuffer input, byte recordMajorVersion, byte recordMinorVersion, int recordLength) throws SSLException
exploreSNIExtback to summary
private static List<SNIServerName> exploreSNIExt(ByteBuffer input, int extLen) throws SSLException
exploreTLSRecordback to summary
private static List<SNIServerName> exploreTLSRecord(ByteBuffer input, byte firstByte, byte secondByte, byte thirdByte) throws SSLException
getInt16back to summary
private static int getInt16(ByteBuffer input)
getInt24back to summary
private static int getInt24(ByteBuffer input)
getInt8back to summary
private static int getInt8(ByteBuffer input)
getRequiredSizeback to summary
public static int getRequiredSize(ByteBuffer source)

Returns the required number of bytes in the source ByteBuffer necessary to explore SSL/TLS connection.

This method tries to parse as few bytes as possible from source byte buffer to get the length of an SSL/TLS record.

This method accesses the source parameter in read-only mode, and does not update the buffer's properties such as capacity, limit, position, and mark values.

Parameters
source:ByteBuffer

a ByteBuffer containing inbound or outbound network data for an SSL/TLS connection.

Returns:int

the required size in byte to explore an SSL/TLS connection

Exceptions
BufferUnderflowException:
if less than RECORD_HEADER_SIZE bytes remaining in source
getRequiredSizeback to summary
public static int getRequiredSize(byte[] source, int offset, int length) throws IOException

Returns the required number of bytes in the source byte array necessary to explore SSL/TLS connection.

This method tries to parse as few bytes as possible from source byte array to get the length of an SSL/TLS record.

Parameters
source:byte[]

a byte array containing inbound or outbound network data for an SSL/TLS connection.

offset:int

the start offset in array source at which the network data is read from.

length:int

the maximum number of bytes to read.

Returns:int

the required size in byte to explore an SSL/TLS connection

Exceptions
BufferUnderflowException:
if less than RECORD_HEADER_SIZE bytes remaining in source
ignoreByteVectorback to summary
private static void ignoreByteVector(ByteBuffer input, int length)
ignoreByteVector8back to summary
private static void ignoreByteVector8(ByteBuffer input)
io.undertow.protocols.ssl back to summary

pack-priv final Class SNISSLExplorer.ExtensionInfo

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final List<String>
pack-priv final List<SNIServerName>

Constructor Summary

AccessConstructor and Description
pack-priv
ExtensionInfo(final List<SNIServerName> sni, final List<String> alpn)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

alpnback to summary
pack-priv final List<String> alpn
sniback to summary
pack-priv final List<SNIServerName> sni

Constructor Detail

ExtensionInfoback to summary
pack-priv ExtensionInfo(final List<SNIServerName> sni, final List<String> alpn)
io.undertow.protocols.ssl back to summary

pack-priv final Class SNISSLExplorer.UnknownServerName

extends SNIServerName
Class Inheritance

Constructor Summary

AccessConstructor and Description
pack-priv
UnknownServerName(int code, byte[] encoded)

Method Summary

Inherited from javax.net.ssl.SNIServerName:
equalsgetEncodedgetTypehashCodetoString

Constructor Detail

UnknownServerNameback to summary
pack-priv UnknownServerName(int code, byte[] encoded)