From dad6e15ffe0ad6d85e8f5a7f61d0ef4cb76cfbae Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Wed, 15 Apr 2015 23:05:10 +0200 Subject: [PATCH] Allow to get version of available OpenSSL library Motivation: Sometimes it's useful to get informations about the available OpenSSL library that is used for the OpenSslEngine. Modifications: Add two new methods which allows to get the available OpenSSL version as either an int or an String. Result: Easy to access details about OpenSSL version. --- .../java/io/netty/handler/ssl/OpenSsl.java | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/handler/src/main/java/io/netty/handler/ssl/OpenSsl.java b/handler/src/main/java/io/netty/handler/ssl/OpenSsl.java index 49e2da42ed..619768aa67 100644 --- a/handler/src/main/java/io/netty/handler/ssl/OpenSsl.java +++ b/handler/src/main/java/io/netty/handler/ssl/OpenSsl.java @@ -118,7 +118,29 @@ public final class OpenSsl { * ALPN. */ public static boolean isAlpnSupported() { - return isAvailable() && SSL.version() >= 0x10002000L; + return version() >= 0x10002000L; + } + + /** + * Returns the version of the used available OpenSSL library or {@code -1} if {@link #isAvailable()} + * returns {@code false}. + */ + public static int version() { + if (isAvailable()) { + return SSL.version(); + } + return -1; + } + + /** + * Returns the version string of the used available OpenSSL library or {@code null} if {@link #isAvailable()} + * returns {@code false}. + */ + public static String versionString() { + if (isAvailable()) { + return SSL.versionString(); + } + return null; } /**