Package io.vertx.core.net
Class PemTrustOptions
- java.lang.Object
-
- io.vertx.core.net.PemTrustOptions
-
- All Implemented Interfaces:
TrustOptions
,Cloneable
public class PemTrustOptions extends Object implements TrustOptions, Cloneable
Certificate Authority options configuring certificates based on Privacy-enhanced Electronic Email (PEM) files. The options is configured with a list of validating certificates.Validating certificates must contain X.509 certificates wrapped in a PEM block:
-----BEGIN CERTIFICATE----- MIIDezCCAmOgAwIBAgIEVmLkwTANBgkqhkiG9w0BAQsFADBuMRAwDgYDVQQGEwdV ... z5+DuODBJUQst141Jmgq8bS543IU/5apcKQeGNxEyQ== -----END CERTIFICATE-----
The certificates can either be loaded by Vert.x from the filesystem:HttpServerOptions options = new HttpServerOptions(); options.setPemTrustOptions(new PemTrustOptions().addCertPath("/cert.pem"));
Or directly provided as a buffer:Buffer cert = vertx.fileSystem().readFileBlocking("/cert.pem"); HttpServerOptions options = new HttpServerOptions(); options.setPemTrustOptions(new PemTrustOptions().addCertValue(cert));
- Author:
- Julien Viet, Tim Fox
-
-
Constructor Summary
Constructors Constructor Description PemTrustOptions()
Default constructorPemTrustOptions(JsonObject json)
Create options from JSONPemTrustOptions(PemTrustOptions other)
Copy constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PemTrustOptions
addCertPath(String certPath)
Add a certificate pathPemTrustOptions
addCertValue(Buffer certValue)
Add a certificate valuePemTrustOptions
copy()
boolean
equals(Object obj)
List<String>
getCertPaths()
List<Buffer>
getCertValues()
io.vertx.core.net.impl.KeyStoreHelper
getHelper(Vertx vertx)
TrustManagerFactory
getTrustManagerFactory(Vertx vertx)
Create and return the trust manager factory for these options.int
hashCode()
KeyStore
loadKeyStore(Vertx vertx)
Load and return a Java keystore.JsonObject
toJson()
Convert to JSONjava.util.function.Function<String,TrustManager[]>
trustManagerMapper(Vertx vertx)
Returns a function that maps SNI server names to aTrustManagerFactory
instance.
-
-
-
Constructor Detail
-
PemTrustOptions
public PemTrustOptions()
Default constructor
-
PemTrustOptions
public PemTrustOptions(PemTrustOptions other)
Copy constructor- Parameters:
other
- the options to copy
-
PemTrustOptions
public PemTrustOptions(JsonObject json)
Create options from JSON- Parameters:
json
- the JSON
-
-
Method Detail
-
toJson
public JsonObject toJson()
Convert to JSON- Returns:
- the JSON
-
getCertPaths
public List<String> getCertPaths()
- Returns:
- the certificate paths used to locate certificates
-
addCertPath
public PemTrustOptions addCertPath(String certPath) throws NullPointerException
Add a certificate path- Parameters:
certPath
- the path to add- Returns:
- a reference to this, so the API can be used fluently
- Throws:
NullPointerException
-
addCertValue
public PemTrustOptions addCertValue(Buffer certValue) throws NullPointerException
Add a certificate value- Parameters:
certValue
- the value to add- Returns:
- a reference to this, so the API can be used fluently
- Throws:
NullPointerException
-
loadKeyStore
public KeyStore loadKeyStore(Vertx vertx) throws Exception
Load and return a Java keystore.- Parameters:
vertx
- the vertx instance- Returns:
- the
KeyStore
- Throws:
Exception
-
getTrustManagerFactory
public TrustManagerFactory getTrustManagerFactory(Vertx vertx) throws Exception
Description copied from interface:TrustOptions
Create and return the trust manager factory for these options.The returned trust manager factory should be already initialized and ready to use.
- Specified by:
getTrustManagerFactory
in interfaceTrustOptions
- Parameters:
vertx
- the vertx instance- Returns:
- the trust manager factory
- Throws:
Exception
-
trustManagerMapper
public java.util.function.Function<String,TrustManager[]> trustManagerMapper(Vertx vertx) throws Exception
Description copied from interface:TrustOptions
Returns a function that maps SNI server names to aTrustManagerFactory
instance. The returnedTrustManagerFactory
must already be initialized and ready to use. The mapper is only used when the server has SNI enabled and the client indicated a server name. The returned function may returnnull
in which caseTrustOptions.getTrustManagerFactory(Vertx)
is used as fallback.- Specified by:
trustManagerMapper
in interfaceTrustOptions
- Parameters:
vertx
- the vertx instance- Returns:
- the trustManager
- Throws:
Exception
-
copy
public PemTrustOptions copy()
- Specified by:
copy
in interfaceTrustOptions
- Returns:
- a copy of these options
-
-