-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ALPN support merged in JDK9 and will eventually be backported into JDK8. However, not every consumer of JSS will necessarily upgrade to a newer JDK8 version. While support has landed upstream, Fedora 32 and Fedora 33 haven't yet seen a backport yet. This likely means that RHEL also won't see a backport. Introduce a small reflection-based compatibility layer to see if the class supports ALPN and if so, use the value from it. Signed-off-by: Alexander Scheel <[email protected]>
- Loading branch information
Showing
2 changed files
with
24 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
package org.mozilla.jss.util; | ||
|
||
import java.lang.reflect.Method; | ||
|
||
import javax.net.ssl.SSLParameters; | ||
|
||
public class JDKCompat { | ||
public static class SSLParametersHelper { | ||
public static String[] getApplicationProtocols(SSLParameters inst) { | ||
try { | ||
Method getter = inst.getClass().getMethod("getApplicationProtocols"); | ||
Object result = getter.invoke(inst); | ||
return (String[]) result; | ||
} catch (NoSuchMethodException nsme) { | ||
return null; | ||
} catch (Throwable t) { | ||
throw new RuntimeException(t.getMessage(), t); | ||
} | ||
} | ||
} | ||
} |