SSLParameters can be created via the constructors in this class.
 Objects can also be obtained using the getSSLParameters()
 methods in
 SSLSocket and
 SSLServerSocket and
 SSLEngine or the
 getDefaultSSLParameters() and
 getSupportedSSLParameters()
 methods in SSLContext.
 
 SSLParameters can be applied to a connection via the methods
 SSLSocket.setSSLParameters() and
 SSLServerSocket.setSSLParameters()
 and SSLEngine.setSSLParameters().
 
For example:
     SSLParameters p = sslSocket.getSSLParameters();
     p.setProtocols(new String[] { "TLSv1.2" });
     p.setCipherSuites(
         new String[] { "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", ... });
     p.setApplicationProtocols(new String[] {"h2", "http/1.1"});
     sslSocket.setSSLParameters(p);
 - Since:
- 1.6
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionConstructs SSLParameters.SSLParameters(String[] cipherSuites) Constructs SSLParameters from the specified array of ciphersuites.SSLParameters(String[] cipherSuites, String[] protocols) Constructs SSLParameters from the specified array of ciphersuites and protocols.
- 
Method SummaryModifier and TypeMethodDescriptionReturns the cryptographic algorithm constraints.String[]Returns a prioritized array of application-layer protocol names that can be negotiated over the SSL/TLS/DTLS protocols.String[]Returns a copy of the array of ciphersuites or null if none have been set.booleanReturns whether DTLS handshake retransmissions should be enabled.Gets the endpoint identification algorithm.intReturns the maximum expected network packet size in bytes for SSL/TLS/DTLS records.booleanReturns whether client authentication should be required.String[]Returns a copy of the array of protocols or null if none have been set.final List<SNIServerName>Returns aListcontaining allSNIServerNames of the Server Name Indication (SNI) parameter, or null if none has been set.final Collection<SNIMatcher>Returns aCollectioncontaining allSNIMatchers of the Server Name Indication (SNI) parameter, or null if none has been set.final booleanReturns whether the local cipher suites preference should be honored.booleanReturns whether client authentication should be requested.voidsetAlgorithmConstraints(AlgorithmConstraints constraints) Sets the cryptographic algorithm constraints, which will be used in addition to any configured by the runtime environment.voidsetApplicationProtocols(String[] protocols) Sets the prioritized array of application-layer protocol names that can be negotiated over the SSL/TLS/DTLS protocols.voidsetCipherSuites(String[] cipherSuites) Sets the array of ciphersuites.voidsetEnableRetransmissions(boolean enableRetransmissions) Sets whether DTLS handshake retransmissions should be enabled.voidsetEndpointIdentificationAlgorithm(String algorithm) Sets the endpoint identification algorithm.voidsetMaximumPacketSize(int maximumPacketSize) Sets the maximum expected network packet size in bytes for SSL/TLS/DTLS records.voidsetNeedClientAuth(boolean needClientAuth) Sets whether client authentication should be required.voidsetProtocols(String[] protocols) Sets the array of protocols.final voidsetServerNames(List<SNIServerName> serverNames) Sets the desiredSNIServerNames of the Server Name Indication (SNI) parameter.final voidsetSNIMatchers(Collection<SNIMatcher> matchers) Sets theSNIMatchers of the Server Name Indication (SNI) parameter.final voidsetUseCipherSuitesOrder(boolean honorOrder) Sets whether the local cipher suites preference should be honored.voidsetWantClientAuth(boolean wantClientAuth) Sets whether client authentication should be requested.
- 
Constructor Details- 
SSLParameterspublic SSLParameters()Constructs SSLParameters.The values of cipherSuites, protocols, cryptographic algorithm constraints, endpoint identification algorithm, server names and server name matchers are set to null; useCipherSuitesOrder, wantClientAuth and needClientAuth are set tofalse; enableRetransmissions is set totrue; maximum network packet size is set to0.
- 
SSLParametersConstructs SSLParameters from the specified array of ciphersuites.Calling this constructor is equivalent to calling the no-args constructor followed by setCipherSuites(cipherSuites);. Note that the standard list of cipher suite names may be found in the JSSE Cipher Suite Names section of the Java Cryptography Architecture Standard Algorithm Name Documentation. Providers may support cipher suite names not found in this list.- Parameters:
- cipherSuites- the array of ciphersuites (or null)
 
- 
SSLParametersConstructs SSLParameters from the specified array of ciphersuites and protocols.Calling this constructor is equivalent to calling the no-args constructor followed by setCipherSuites(cipherSuites); setProtocols(protocols);. Note that the standard list of cipher suite names may be found in the JSSE Cipher Suite Names section of the Java Cryptography Architecture Standard Algorithm Name Documentation. Providers may support cipher suite names not found in this list.- Parameters:
- cipherSuites- the array of ciphersuites (or null)
- protocols- the array of protocols (or null)
 
 
- 
- 
Method Details- 
getCipherSuitesReturns a copy of the array of ciphersuites or null if none have been set.The returned array includes cipher suites from the list of standard cipher suite names in the JSSE Cipher Suite Names section of the Java Cryptography Architecture Standard Algorithm Name Documentation, and may also include other cipher suites that the provider supports. - Returns:
- a copy of the array of ciphersuites or null if none have been set.
 
- 
setCipherSuitesSets the array of ciphersuites.- Parameters:
- cipherSuites- the array of ciphersuites (or null). Note that the standard list of cipher suite names may be found in the JSSE Cipher Suite Names section of the Java Cryptography Architecture Standard Algorithm Name Documentation. Providers may support cipher suite names not found in this list or might not use the recommended name for a certain cipher suite.
 
- 
getProtocolsReturns a copy of the array of protocols or null if none have been set.- Returns:
- a copy of the array of protocols or null if none have been set.
 
- 
setProtocolsSets the array of protocols.- Parameters:
- protocols- the array of protocols (or null)
 
- 
getWantClientAuthpublic boolean getWantClientAuth()Returns whether client authentication should be requested.- Returns:
- whether client authentication should be requested.
 
- 
setWantClientAuthpublic void setWantClientAuth(boolean wantClientAuth) Sets whether client authentication should be requested. Calling this method clears theneedClientAuthflag.- Parameters:
- wantClientAuth- whether client authentication should be requested
 
- 
getNeedClientAuthpublic boolean getNeedClientAuth()Returns whether client authentication should be required.- Returns:
- whether client authentication should be required.
 
- 
setNeedClientAuthpublic void setNeedClientAuth(boolean needClientAuth) Sets whether client authentication should be required. Calling this method clears thewantClientAuthflag.- Parameters:
- needClientAuth- whether client authentication should be required
 
- 
getAlgorithmConstraintsReturns the cryptographic algorithm constraints.- Returns:
- the cryptographic algorithm constraints, or null if the constraints have not been set
- Since:
- 1.7
- See Also:
 
- 
setAlgorithmConstraintsSets the cryptographic algorithm constraints, which will be used in addition to any configured by the runtime environment.If the constraintsparameter is non-null, every cryptographic algorithm, key and algorithm parameters used in the SSL/TLS/DTLS handshake must be permitted by the constraints.- Parameters:
- constraints- the algorithm constraints (or null)
- Since:
- 1.7
 
- 
getEndpointIdentificationAlgorithmGets the endpoint identification algorithm.- Returns:
- the endpoint identification algorithm, or null if none has been set.
- Since:
- 1.7
- See Also:
 
- 
setEndpointIdentificationAlgorithmSets the endpoint identification algorithm.If the algorithmparameter is non-null or non-empty, the endpoint identification/verification procedures must be handled during SSL/TLS/DTLS handshaking. This is to prevent man-in-the-middle attacks.- Parameters:
- algorithm- The standard string name of the endpoint identification algorithm (or null). See the Java Security Standard Algorithm Names document for information about standard algorithm names.
- Since:
- 1.7
- See Also:
 
- 
setServerNamesSets the desiredSNIServerNames of the Server Name Indication (SNI) parameter.This method is only useful to SSLSockets orSSLEngines operating in client mode.Note that the serverNameslist is cloned to protect against subsequent modification.- Parameters:
- serverNames- the list of desired- SNIServerNames (or null)
- Throws:
- NullPointerException- if the- serverNamescontains- nullelement
- IllegalArgumentException- if the- serverNamescontains more than one name of the same name type
- Since:
- 1.8
- See Also:
 
- 
getServerNamesReturns aListcontaining allSNIServerNames of the Server Name Indication (SNI) parameter, or null if none has been set.This method is only useful to SSLSockets orSSLEngines operating in client mode.For SSL/TLS/DTLS connections, the underlying SSL/TLS/DTLS provider may specify a default value for a certain server name type. In client mode, it is recommended that, by default, providers should include the server name indication whenever the server can be located by a supported server name type. It is recommended that providers initialize default Server Name Indications when creating SSLSocket/SSLEngines. In the following examples, the server name could be represented by an instance ofSNIHostNamewhich has been initialized with the hostname "www.example.com" and typeStandardConstants.SNI_HOST_NAME.Socket socket = sslSocketFactory.createSocket("www.example.com", 443);orSSLEngine engine = sslContext.createSSLEngine("www.example.com", 443);- Returns:
- null or an immutable list of non-null SNIServerNames
- Since:
- 1.8
- See Also:
 
- 
setSNIMatchersSets theSNIMatchers of the Server Name Indication (SNI) parameter.This method is only useful to SSLSockets orSSLEngines operating in server mode.Note that the matcherscollection is cloned to protect against subsequent modification.- Parameters:
- matchers- the collection of- SNIMatchers (or null)
- Throws:
- NullPointerException- if the- matcherscontains- nullelement
- IllegalArgumentException- if the- matcherscontains more than one name of the same name type
- Since:
- 1.8
- See Also:
 
- 
getSNIMatchersReturns aCollectioncontaining allSNIMatchers of the Server Name Indication (SNI) parameter, or null if none has been set.This method is only useful to SSLSockets orSSLEngines operating in server mode.For better interoperability, providers generally will not define default matchers so that by default servers will ignore the SNI extension and continue the handshake. - Returns:
- null or an immutable collection of non-null SNIMatchers
- Since:
- 1.8
- See Also:
 
- 
setUseCipherSuitesOrderpublic final void setUseCipherSuitesOrder(boolean honorOrder) Sets whether the local cipher suites preference should be honored.- Parameters:
- honorOrder- whether local cipher suites order in- #getCipherSuitesshould be honored during SSL/TLS/DTLS handshaking.
- Since:
- 1.8
- See Also:
 
- 
getUseCipherSuitesOrderpublic final boolean getUseCipherSuitesOrder()Returns whether the local cipher suites preference should be honored.- Returns:
- whether local cipher suites order in #getCipherSuitesshould be honored during SSL/TLS/DTLS handshaking.
- Since:
- 1.8
- See Also:
 
- 
setEnableRetransmissionspublic void setEnableRetransmissions(boolean enableRetransmissions) Sets whether DTLS handshake retransmissions should be enabled. This method only applies to DTLS.- Parameters:
- enableRetransmissions-- trueindicates that DTLS handshake retransmissions should be enabled;- falseindicates that DTLS handshake retransmissions should be disabled
- Since:
- 9
- See Also:
 
- 
getEnableRetransmissionspublic boolean getEnableRetransmissions()Returns whether DTLS handshake retransmissions should be enabled. This method only applies to DTLS.- Returns:
- true, if DTLS handshake retransmissions should be enabled
- Since:
- 9
- See Also:
 
- 
setMaximumPacketSizepublic void setMaximumPacketSize(int maximumPacketSize) Sets the maximum expected network packet size in bytes for SSL/TLS/DTLS records.- API Note:
- It is recommended that if possible, the maximum packet size should not be less than 256 bytes so that small handshake messages, such as HelloVerifyRequests, are not fragmented.
- Implementation Note:
- If the maximum packet size is too small to hold a minimal record, an implementation may attempt to generate as minimal records as possible. However, this may cause a generated packet to be larger than the maximum packet size.
- Parameters:
- maximumPacketSize- the maximum expected network packet size in bytes, or- 0to use the implicit size that is automatically specified by the underlying implementation.
- Throws:
- IllegalArgumentException- if- maximumPacketSizeis negative.
- Since:
- 9
- See Also:
 
- 
getMaximumPacketSizepublic int getMaximumPacketSize()Returns the maximum expected network packet size in bytes for SSL/TLS/DTLS records.- API Note:
- The implicit size may not be a fixed value, especially for a DTLS protocols implementation.
- Implementation Note:
- For SSL/TLS/DTLS connections, the underlying provider
           should calculate and specify the implicit value of the
           maximum expected network packet size if it is not
           configured explicitly.  For any connection populated
           object, this method should never return 0so that applications can retrieve the actual implicit size of the underlying implementation.An implementation should attempt to comply with the maximum packet size configuration. However, if the maximum packet size is too small to hold a minimal record, an implementation may try to generate as minimal records as possible. This may cause a generated packet to be larger than the maximum packet size. 
- Returns:
- the maximum expected network packet size, or 0if use the implicit size that is automatically specified by the underlying implementation and this object has not been populated by any connection.
- Since:
- 9
- See Also:
 
- 
getApplicationProtocolsReturns a prioritized array of application-layer protocol names that can be negotiated over the SSL/TLS/DTLS protocols.The array could be empty (zero-length), in which case protocol indications will not be used. This method will return a new array each time it is invoked. - Returns:
- a non-null, possibly zero-length array of application protocol
         Strings. The array is ordered based on protocol preference, withprotocols[0]being the most preferred.
- Since:
- 9
- See Also:
 
- 
setApplicationProtocolsSets the prioritized array of application-layer protocol names that can be negotiated over the SSL/TLS/DTLS protocols.If application-layer protocols are supported by the underlying SSL/TLS implementation, this method configures which values can be negotiated by protocols such as RFC 7301 , the Application Layer Protocol Negotiation (ALPN). If this end of the connection is expected to offer application protocol values, all protocols configured by this method will be sent to the peer. If this end of the connection is expected to select the application protocol value, the protocolsconfigured by this method are compared with those sent by the peer. The first matched value becomes the negotiated value. If none of theprotocolswere actually requested by the peer, the underlying protocol will determine what action to take. (For example, ALPN will send a"no_application_protocol"alert and terminate the connection.)The Stringvalues must be presented using the network byte representation expected by the peer. For example, if an ALPNStringshould be exchanged usingUTF-8, theStringshould be converted to itsbyte[]representation and stored as a byte-orientedStringbefore calling this method.// MEETEI MAYEK LETTERS HUK UN I (Unicode 0xabcd->0xabcf): 2 bytes byte[] bytes = "\uabcd\uabce\uabcf" .getBytes(StandardCharsets.UTF_8); String HUK_UN_I = new String(bytes, StandardCharsets.ISO_8859_1); // 0x00-0xFF: 1 byte String rfc7301Grease8A = "\u008A\u008A"; SSLParameters p = sslSocket.getSSLParameters(); p.setApplicationProtocols(new String[] { "h2", "http/1.1", rfc7301Grease8A, HUK_UN_I}); sslSocket.setSSLParameters(p);- Implementation Requirements:
- This method will make a copy of the protocolsarray.
- Parameters:
- protocols- an ordered array of application protocols, with- protocols[0]being the most preferred. If the array is empty (zero-length), protocol indications will not be used.
- Throws:
- IllegalArgumentException- if protocols is null, or if any element in a non-empty array is null or an empty (zero-length) string
- Since:
- 9
- See Also:
 
 
-