Top Description Fields Constructors Methods
io.vertx.core.net

public Class PemKeyCertOptions

extends Object
implements KeyCertOptions
Class Inheritance
All Implemented Interfaces
io.vertx.core.net.KeyCertOptions
Annotations
@DataObject
@JsonGen
publicConverter:false
Imports
io.vertx.codegen.annotations.DataObject, .GenIgnore, io.vertx.codegen.json.annotations.JsonGen, io.vertx.core.Vertx, io.vertx.core.buffer.Buffer, io.vertx.core.impl.Arguments, .VertxInternal, io.vertx.core.json.JsonObject, io.vertx.core.net.impl.KeyStoreHelper, javax.net.ssl.KeyManagerFactory, .X509KeyManager, java.security.KeyStore, java.util.ArrayList, .List, .Objects, java.util.function.Function

Key store options configuring a list of private key and its certificate based on Privacy-enhanced Electronic Email (PEM) files.

A key file must contain a non encrypted private key in PKCS8 format wrapped in a PEM block, for example:

-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDV6zPk5WqLwS0a
...
K5xBhtm1AhdnZjx5KfW3BecE
-----END PRIVATE KEY-----

Or contain a non encrypted private key in PKCS1 format wrapped in a PEM block, for example:

-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAlO4gbHeFb/fmbUF/tOJfNPJumJUEqgzAzx8MBXv9Acyw9IRa
...
zJ14Yd+t2fsLYVs2H0gxaA4DW6neCzgY3eKpSU0EBHUCFSXp/1+/
-----END RSA PRIVATE KEY-----

A certificate file must contain an X.509 certificate wrapped in a PEM block, for example:

-----BEGIN CERTIFICATE-----
MIIDezCCAmOgAwIBAgIEZOI/3TANBgkqhkiG9w0BAQsFADBuMRAwDgYDVQQGEwdV
...
+tmLSvYS39O2nqIzzAUfztkYnUlZmB0l/mKkVqbGJA==
-----END CERTIFICATE-----
Keys and certificates can either be loaded by Vert.x from the filesystem:

HttpServerOptions options = new HttpServerOptions();
options.setPemKeyCertOptions(new PemKeyCertOptions().setKeyPath("/mykey.pem").setCertPath("/mycert.pem"));
Or directly provided as a buffer:

Buffer key = vertx.fileSystem().readFileBlocking("/mykey.pem");
Buffer cert = vertx.fileSystem().readFileBlocking("/mycert.pem");
options.setPemKeyCertOptions(new PemKeyCertOptions().setKeyValue(key).setCertValue(cert));
Several key/certificate pairs can be used:

HttpServerOptions options = new HttpServerOptions();
options.setPemKeyCertOptions(new PemKeyCertOptions()
   .addKeyPath("/mykey1.pem").addCertPath("/mycert1.pem")
   .addKeyPath("/mykey2.pem").addCertPath("/mycert2.pem"));
Authors
Julien Viet, Tim Fox

Field Summary

Modifier and TypeField and Description
private List<String>
private List<Buffer>
private KeyStoreHelper
private List<String>
private List<Buffer>

Constructor Summary

AccessConstructor and Description
public
PemKeyCertOptions()

Default constructor

public
PemKeyCertOptions(PemKeyCertOptions
the options to copy
other
)

Copy constructor

public
PemKeyCertOptions(JsonObject
the JSON
json
)
References Deprecated JsonObject is deprecated or references (maybe indirectly) at least one deprecated element.

Create options from JSON

Method Summary

Modifier and TypeMethod and Description
public PemKeyCertOptions

Returns:

a reference to this, so the API can be used fluently
addCertPath
(String
the path to the certificate file
certPath
)

Add a path to a certificate file

public PemKeyCertOptions

Returns:

a reference to this, so the API can be used fluently
addCertValue
(Buffer
the certificate to add
certValue
)
References Deprecated Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

Add a certificate as a buffer

public PemKeyCertOptions

Returns:

a reference to this, so the API can be used fluently
addKeyPath
(String
the path to the key file
keyPath
)

Add a path to a key file

public PemKeyCertOptions

Returns:

a reference to this, so the API can be used fluently
addKeyValue
(Buffer
the key to add
keyValue
)
References Deprecated Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

Add a key as a buffer

public PemKeyCertOptions
public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public String

Returns:

the path to the certificate file
getCertPath
()

Get the path to the first certificate file

public List<String>

Returns:

the paths to the certificates files
getCertPaths
()

Get all the paths to the certificates files

public Buffer

Returns:

the first certificate as a buffer
getCertValue
()
References Deprecated Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

Get the first certificate as a buffer

public List<Buffer>

Returns:

certificates as a list of buffers
getCertValues
()

Get all the certificates as a list of buffer

pack-priv KeyStoreHelper
public KeyManagerFactory
getKeyManagerFactory(Vertx
the vertx instance
vertx
)

Implements io.vertx.core.net.KeyCertOptions.getKeyManagerFactory.

Create and return the key manager factory for these options.

public String

Returns:

the path to the key file
getKeyPath
()

Get the path to the first key file

public List<String>

Returns:

the paths to the keys files
getKeyPaths
()

Get all the paths to the key files

public Buffer

Returns:

the first key as a buffer
getKeyValue
()
References Deprecated Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

Get the first key as a buffer

public List<Buffer>

Returns:

keys as a list of buffers
getKeyValues
()

Get all the keys as a list of buffer

private void
init()

public Function<String, KeyManagerFactory>
keyManagerFactoryMapper(Vertx vertx)

Overrides default io.vertx.core.net.KeyCertOptions.keyManagerFactoryMapper.

Returns a function that maps SNI server names to KeyManagerFactory instance.

public Function<String, X509KeyManager>
keyManagerMapper(Vertx vertx)

Overrides default io.vertx.core.net.KeyCertOptions.keyManagerMapper.

Returns a function that maps SNI server names to X509KeyManager instance.

public KeyStore

Returns:

the KeyStore
loadKeyStore
(Vertx
the vertx instance
vertx
)

Load and return a Java keystore.

public PemKeyCertOptions

Returns:

a reference to this, so the API can be used fluently
setCertPath
(String
the path to the certificate
certPath
)

Set the path of the first certificate, replacing the previous certificates paths

public PemKeyCertOptions

Returns:

a reference to this, so the API can be used fluently
setCertPaths
(List<String>
the paths to the certificates files
certPaths
)

Set all the paths to the certificates files

public PemKeyCertOptions

Returns:

a reference to this, so the API can be used fluently
setCertValue
(Buffer
the first certificate as a buffer
certValue
)
References Deprecated Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

Set the first certificate as a buffer, replacing the previous certificates buffers

public PemKeyCertOptions

Returns:

a reference to this, so the API can be used fluently
setCertValues
(List<Buffer>
the certificates as a list of buffer
certValues
)

Set all the certificates as a list of buffer

public PemKeyCertOptions

Returns:

a reference to this, so the API can be used fluently
setKeyPath
(String
the path to the first key file
keyPath
)

Set the path of the first key file, replacing the keys paths

public PemKeyCertOptions

Returns:

a reference to this, so the API can be used fluently
setKeyPaths
(List<String>
the paths to the keys files
keyPaths
)

Set all the paths to the keys files

public PemKeyCertOptions

Returns:

a reference to this, so the API can be used fluently
setKeyValue
(Buffer
key as a buffer
keyValue
)
References Deprecated Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

Set the first key a a buffer, replacing the previous keys buffers

public PemKeyCertOptions

Returns:

a reference to this, so the API can be used fluently
setKeyValues
(List<Buffer>
the keys as a list of buffer
keyValues
)

Set all the keys as a list of buffer

public JsonObject

Returns:

the JSON
toJson
()
References Deprecated JsonObject is deprecated or references (maybe indirectly) at least one deprecated element.

Convert to JSON

Inherited from java.lang.Object:
clonefinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

certPathsback to summary
private List<String> certPaths
certValuesback to summary
private List<Buffer> certValues
helperback to summary
private KeyStoreHelper helper
keyPathsback to summary
private List<String> keyPaths
keyValuesback to summary
private List<Buffer> keyValues

Constructor Detail

PemKeyCertOptionsback to summary
public PemKeyCertOptions()

Default constructor

PemKeyCertOptionsback to summary
public PemKeyCertOptions(PemKeyCertOptions other)

Copy constructor

Parameters
other:PemKeyCertOptions

the options to copy

PemKeyCertOptionsback to summary
public PemKeyCertOptions(JsonObject json)

References Deprecated

JsonObject is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Create options from JSON

Parameters
json:JsonObject

the JSON

Method Detail

addCertPathback to summary
public PemKeyCertOptions addCertPath(String certPath)

Add a path to a certificate file

Parameters
certPath:String

the path to the certificate file

Returns:PemKeyCertOptions

a reference to this, so the API can be used fluently

Annotations
@GenIgnore
addCertValueback to summary
public PemKeyCertOptions addCertValue(Buffer certValue)

References Deprecated

Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Add a certificate as a buffer

Parameters
certValue:Buffer

the certificate to add

Returns:PemKeyCertOptions

a reference to this, so the API can be used fluently

Annotations
@GenIgnore
addKeyPathback to summary
public PemKeyCertOptions addKeyPath(String keyPath)

Add a path to a key file

Parameters
keyPath:String

the path to the key file

Returns:PemKeyCertOptions

a reference to this, so the API can be used fluently

Annotations
@GenIgnore
addKeyValueback to summary
public PemKeyCertOptions addKeyValue(Buffer keyValue)

References Deprecated

Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Add a key as a buffer

Parameters
keyValue:Buffer

the key to add

Returns:PemKeyCertOptions

a reference to this, so the API can be used fluently

Annotations
@GenIgnore
copyback to summary
public PemKeyCertOptions copy()

Implements io.vertx.core.net.KeyCertOptions.copy.

Returns:PemKeyCertOptions

Doc from io.vertx.core.net.KeyCertOptions.copy.

a copy of these options

Annotations
@Override
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getCertPathback to summary
public String getCertPath()

Get the path to the first certificate file

Returns:String

the path to the certificate file

Annotations
@GenIgnore
getCertPathsback to summary
public List<String> getCertPaths()

Get all the paths to the certificates files

Returns:List<String>

the paths to the certificates files

getCertValueback to summary
public Buffer getCertValue()

References Deprecated

Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Get the first certificate as a buffer

Returns:Buffer

the first certificate as a buffer

Annotations
@GenIgnore
getCertValuesback to summary
public List<Buffer> getCertValues()

Get all the certificates as a list of buffer

Returns:List<Buffer>

certificates as a list of buffers

getHelperback to summary
pack-priv KeyStoreHelper getHelper(Vertx vertx) throws Exception
getKeyManagerFactoryback to summary
public KeyManagerFactory getKeyManagerFactory(Vertx vertx) throws Exception

Implements io.vertx.core.net.KeyCertOptions.getKeyManagerFactory.

Doc from io.vertx.core.net.KeyCertOptions.getKeyManagerFactory.

Create and return the key manager factory for these options.

The returned key manager factory should be already initialized and ready to use.

Parameters
vertx:Vertx

the vertx instance

Returns:KeyManagerFactory

the key manager factory

Annotations
@Override
getKeyPathback to summary
public String getKeyPath()

Get the path to the first key file

Returns:String

the path to the key file

Annotations
@GenIgnore
getKeyPathsback to summary
public List<String> getKeyPaths()

Get all the paths to the key files

Returns:List<String>

the paths to the keys files

getKeyValueback to summary
public Buffer getKeyValue()

References Deprecated

Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Get the first key as a buffer

Returns:Buffer

the first key as a buffer

Annotations
@GenIgnore
getKeyValuesback to summary
public List<Buffer> getKeyValues()

Get all the keys as a list of buffer

Returns:List<Buffer>

keys as a list of buffers

initback to summary
private void init()
keyManagerFactoryMapperback to summary
public Function<String, KeyManagerFactory> keyManagerFactoryMapper(Vertx vertx) throws Exception

Overrides default io.vertx.core.net.KeyCertOptions.keyManagerFactoryMapper.

Doc from io.vertx.core.net.KeyCertOptions.keyManagerFactoryMapper.

Returns a function that maps SNI server names to KeyManagerFactory instance. The returned KeyManagerFactory must satisfies these rules:

  • The store private key must match the indicated server name for a null alias.
  • The store certificate chain must match the indicated server name for a null alias.
The mapper is only used when the server has SNI enabled and the client indicated a server name.

The returned function may return null in which case the default key manager provided by getKeyManagerFactory(Vertx) will be used.

Annotations
@Override
keyManagerMapperback to summary
public Function<String, X509KeyManager> keyManagerMapper(Vertx vertx) throws Exception

Overrides default io.vertx.core.net.KeyCertOptions.keyManagerMapper.

Doc from io.vertx.core.net.KeyCertOptions.keyManagerMapper.

Returns a function that maps SNI server names to X509KeyManager instance. The returned X509KeyManager must satisfies these rules:

The mapper is only used when the server has SNI enabled and the client indicated a server name.

The returned function may return null in which case the default key manager provided by getKeyManagerFactory(Vertx) will be used.

Annotations
@Override
loadKeyStoreback to summary
public KeyStore loadKeyStore(Vertx vertx) throws Exception

Load and return a Java keystore.

Parameters
vertx:Vertx

the vertx instance

Returns:KeyStore

the KeyStore

setCertPathback to summary
public PemKeyCertOptions setCertPath(String certPath)

Set the path of the first certificate, replacing the previous certificates paths

Parameters
certPath:String

the path to the certificate

Returns:PemKeyCertOptions

a reference to this, so the API can be used fluently

setCertPathsback to summary
public PemKeyCertOptions setCertPaths(List<String> certPaths)

Set all the paths to the certificates files

Parameters
certPaths:List<String>

the paths to the certificates files

Returns:PemKeyCertOptions

a reference to this, so the API can be used fluently

setCertValueback to summary
public PemKeyCertOptions setCertValue(Buffer certValue)

References Deprecated

Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Set the first certificate as a buffer, replacing the previous certificates buffers

Parameters
certValue:Buffer

the first certificate as a buffer

Returns:PemKeyCertOptions

a reference to this, so the API can be used fluently

setCertValuesback to summary
public PemKeyCertOptions setCertValues(List<Buffer> certValues)

Set all the certificates as a list of buffer

Parameters
certValues:List<Buffer>

the certificates as a list of buffer

Returns:PemKeyCertOptions

a reference to this, so the API can be used fluently

setKeyPathback to summary
public PemKeyCertOptions setKeyPath(String keyPath)

Set the path of the first key file, replacing the keys paths

Parameters
keyPath:String

the path to the first key file

Returns:PemKeyCertOptions

a reference to this, so the API can be used fluently

setKeyPathsback to summary
public PemKeyCertOptions setKeyPaths(List<String> keyPaths)

Set all the paths to the keys files

Parameters
keyPaths:List<String>

the paths to the keys files

Returns:PemKeyCertOptions

a reference to this, so the API can be used fluently

setKeyValueback to summary
public PemKeyCertOptions setKeyValue(Buffer keyValue)

References Deprecated

Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Set the first key a a buffer, replacing the previous keys buffers

Parameters
keyValue:Buffer

key as a buffer

Returns:PemKeyCertOptions

a reference to this, so the API can be used fluently

setKeyValuesback to summary
public PemKeyCertOptions setKeyValues(List<Buffer> keyValues)

Set all the keys as a list of buffer

Parameters
keyValues:List<Buffer>

the keys as a list of buffer

Returns:PemKeyCertOptions

a reference to this, so the API can be used fluently

toJsonback to summary
public JsonObject toJson()

References Deprecated

JsonObject is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Convert to JSON

Returns:JsonObject

the JSON