Class TlsUtils
java.lang.Object
com.rabbitmq.client.impl.TlsUtils
Utility to extract information from X509 certificates.
- Since:
- 5.7.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Map<String, BiFunction<byte[], X509Certificate, String>> private static final org.slf4j.Loggerprivate static String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static StringauthorityKeyIdentifier(byte[] derOctetString) private static StringbasicConstraints(byte[] derOctetString) private static StringextendedKeyUsage(byte[] derOctetString, X509Certificate certificate) static StringextensionPrettyPrint(String oid, byte[] derOctetString, X509Certificate certificate) Human-readable representation of an X509 certificate extension.private static Stringextensions(X509Certificate certificate) private static StringhexDump(int start, byte[] derOctetString) private static StringkeyUsageBitString(boolean[] keyUsage, byte[] derOctetString) static voidlogPeerCertificateInfo(SSLSession session) Log details on peer certificate and certification chain.private static StringoctetStringHexDump(byte[] derOctetString) static StringpeerCertificateInfo(Certificate certificate, String prefix) Get a string representation of certificate info.private static Stringsans(X509Certificate c, String separator) static StringStrips carriage return (CR) and line feed (LF) characters to mitigate CWE-117.
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
KEY_USAGE
-
EXTENDED_KEY_USAGE
-
PARSING_ERROR
-
EXTENSIONS
-
-
Constructor Details
-
TlsUtils
public TlsUtils()
-
-
Method Details
-
logPeerCertificateInfo
Log details on peer certificate and certification chain.The log level is debug. Common X509 extensions are displayed in a best-effort fashion, a hexadecimal dump is made for less commonly used extensions.
- Parameters:
session- theSSLSessionto extract the certificates from
-
peerCertificateInfo
Get a string representation of certificate info.- Parameters:
certificate- the certificate to analyzeprefix- the line prefix- Returns:
- information about the certificate
-
sans
- Throws:
CertificateParsingException
-
extensionPrettyPrint
public static String extensionPrettyPrint(String oid, byte[] derOctetString, X509Certificate certificate) Human-readable representation of an X509 certificate extension.Common extensions are supported in a best-effort fashion, less commonly used extensions are displayed as an hexadecimal dump.
Extensions come encoded as a DER Octet String, which itself can contain other DER-encoded objects, making a comprehensive support in this utility impossible.
- Parameters:
oid- extension OIDderOctetString- the extension value as a DER octet stringcertificate- the certificate- Returns:
- the OID and the value
- See Also:
-
stripCRLF
-
extensions
-
octetStringHexDump
-
hexDump
-
keyUsageBitString
-
basicConstraints
-
authorityKeyIdentifier
-
extendedKeyUsage
-