Class PemKeyCertOptions
java.lang.Object
io.vertx.core.net.PemKeyCertOptions
- All Implemented Interfaces:
KeyCertOptions
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"));
- Author:
- Julien Viet, Tim Fox
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructorPemKeyCertOptions(JsonObject json) Create options from JSONCopy constructor -
Method Summary
Modifier and TypeMethodDescriptionaddCertPath(String certPath) Add a path to a certificate fileaddCertValue(Buffer certValue) Add a certificate as a bufferaddKeyPath(String keyPath) Add a path to a key fileaddKeyValue(Buffer keyValue) Add a key as a buffercopy()booleanGet the path to the first certificate fileGet all the paths to the certificates filesGet the first certificate as a bufferGet all the certificates as a list of bufferio.vertx.core.net.impl.KeyStoreHelpergetKeyManagerFactory(Vertx vertx) Create and return the key manager factory for these options.Get the path to the first key fileGet all the paths to the key filesGet the first key as a bufferGet all the keys as a list of bufferinthashCode()keyManagerFactoryMapper(Vertx vertx) Returns a function that maps SNI server names toKeyManagerFactoryinstance.loadKeyStore(Vertx vertx) Load and return a Java keystore.setCertPath(String certPath) Set the path of the first certificate, replacing the previous certificates pathssetCertPaths(List<String> certPaths) Set all the paths to the certificates filessetCertValue(Buffer certValue) Set the first certificate as a buffer, replacing the previous certificates bufferssetCertValues(List<Buffer> certValues) Set all the certificates as a list of buffersetKeyPath(String keyPath) Set the path of the first key file, replacing the keys pathssetKeyPaths(List<String> keyPaths) Set all the paths to the keys filessetKeyValue(Buffer keyValue) Set the first key a a buffer, replacing the previous keys bufferssetKeyValues(List<Buffer> keyValues) Set all the keys as a list of buffertoJson()Convert to JSON
-
Constructor Details
-
PemKeyCertOptions
public PemKeyCertOptions()Default constructor -
PemKeyCertOptions
Copy constructor- Parameters:
other- the options to copy
-
PemKeyCertOptions
-
-
Method Details
-
toJson
-
getKeyPath
-
setKeyPath
Set the path of the first key file, replacing the keys paths- Parameters:
keyPath- the path to the first key file- Returns:
- a reference to this, so the API can be used fluently
-
getKeyPaths
-
setKeyPaths
Set all the paths to the keys files- Parameters:
keyPaths- the paths to the keys files- Returns:
- a reference to this, so the API can be used fluently
-
addKeyPath
Add a path to a key file- Parameters:
keyPath- the path to the key file- Returns:
- a reference to this, so the API can be used fluently
-
getKeyValue
-
setKeyValue
Set the first key a a buffer, replacing the previous keys buffers- Parameters:
keyValue- key as a buffer- Returns:
- a reference to this, so the API can be used fluently
-
getKeyValues
-
setKeyValues
Set all the keys as a list of buffer- Parameters:
keyValues- the keys as a list of buffer- Returns:
- a reference to this, so the API can be used fluently
-
addKeyValue
Add a key as a buffer- Parameters:
keyValue- the key to add- Returns:
- a reference to this, so the API can be used fluently
-
getCertPath
Get the path to the first certificate file- Returns:
- the path to the certificate file
-
setCertPath
Set the path of the first certificate, replacing the previous certificates paths- Parameters:
certPath- the path to the certificate- Returns:
- a reference to this, so the API can be used fluently
-
getCertPaths
-
setCertPaths
Set all the paths to the certificates files- Parameters:
certPaths- the paths to the certificates files- Returns:
- a reference to this, so the API can be used fluently
-
addCertPath
Add a path to a certificate file- Parameters:
certPath- the path to the certificate file- Returns:
- a reference to this, so the API can be used fluently
-
getCertValue
Get the first certificate as a buffer- Returns:
- the first certificate as a buffer
-
setCertValue
Set the first certificate as a buffer, replacing the previous certificates buffers- Parameters:
certValue- the first certificate as a buffer- Returns:
- a reference to this, so the API can be used fluently
-
getCertValues
-
setCertValues
Set all the certificates as a list of buffer- Parameters:
certValues- the certificates as a list of buffer- Returns:
- a reference to this, so the API can be used fluently
-
addCertValue
Add a certificate as a buffer- Parameters:
certValue- the certificate to add- Returns:
- a reference to this, so the API can be used fluently
-
equals
-
hashCode
-
copy
- Specified by:
copyin interfaceKeyCertOptions- Returns:
- a copy of these options
-
getHelper
-
loadKeyStore
-
getKeyManagerFactory
Description copied from interface:KeyCertOptionsCreate and return the key manager factory for these options.The returned key manager factory should be already initialized and ready to use.
- Specified by:
getKeyManagerFactoryin interfaceKeyCertOptions- Parameters:
vertx- the vertx instance- Returns:
- the key manager factory
- Throws:
Exception
-
keyManagerFactoryMapper
Description copied from interface:KeyCertOptionsReturns a function that maps SNI server names toKeyManagerFactoryinstance. The returnedKeyManagerFactorymust 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 returned function may return
nullin which case the default key manager provided byKeyCertOptions.getKeyManagerFactory(Vertx)will be used.- Specified by:
keyManagerFactoryMapperin interfaceKeyCertOptions- Throws:
Exception
-