diff --git a/org/mozilla/jss/ssl/javax/JSSEngine.java b/org/mozilla/jss/ssl/javax/JSSEngine.java index 62d908615..3046bd96e 100644 --- a/org/mozilla/jss/ssl/javax/JSSEngine.java +++ b/org/mozilla/jss/ssl/javax/JSSEngine.java @@ -50,6 +50,11 @@ public abstract class JSSEngine extends javax.net.ssl.SSLEngine { */ protected String hostname; + /** + * Certificate alias used by the JSSEngine instance. + */ + protected String certAlias; + /** * Certificate used by this JSSEngine instance. * @@ -235,6 +240,36 @@ public SSLFDProxy getSSLFDProxy() { return ssl_fd; } + /** + * Get the configuration from the current JSSEngine object as a + * JSSParameters object. + * + * This populates the following values, when set: + * - cipher suites + * - protocols + * - need/want client auth + * - certificate alias + * - peer's hostname + * - ALPN protocols + */ + public JSSParameters getSSLParameters() { + JSSParameters ret = new JSSParameters(); + + ret.setCipherSuites(getEnabledCipherSuites()); + ret.setProtocols(getEnabledProtocols()); + if (getNeedClientAuth()) { + ret.setNeedClientAuth(true); + } else if (getWantClientAuth()) { + ret.setWantClientAuth(true); + } + + ret.setAlias(certAlias); + ret.setHostname(hostname); + ret.setApplicationProtocols(alpn_protocols); + + return ret; + } + /** * Set the configuration from the given SSLParameters object onto this * JSSEngine. @@ -344,11 +379,14 @@ public void setCertFromAlias(String alias) throws IllegalArgumentException { if (alias == null) { // Per calling, semantics, get rid of any existing cert/key we // might have. + certAlias = null; cert = null; key = null; return; } + certAlias = alias; + if (key_managers == null || key_managers.length == 0) { String msg = "Missing or null KeyManagers; refusing to search "; msg += "for cert";