public class ApplicationIdentity extends SecureIdentity
UserIdentity| Modifier and Type | Field and Description |
|---|---|
static String |
CERT_FILE_EXTENSIONS |
certificate, privateKey| Constructor and Description |
|---|
ApplicationIdentity()
Create a new empty identity.
|
ApplicationIdentity(Cert certificate,
PrivKey privateKey)
Create a new identity
|
ApplicationIdentity(File certificateFile,
File privateKeyFile,
String privateKeyPassword)
Create an identity with an application certificate.
|
ApplicationIdentity(File storeLocation,
String alias,
String privateKeyPassword,
String keyStorePassword,
String keyStoreType)
Create an identity with an application certificate.
|
ApplicationIdentity(KeyPair... keyPairs)
Create an identity with one or more application certificate.
|
ApplicationIdentity(URL certificateFile,
URL privateKeyFile,
String privateKeyPassword)
Create an identity with an application certificate.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addSoftwareCertificates(SignedSoftwareCertificate[] softwareCertificates)
Deprecated.
this method does nothing as the serverSoftwareCertificates parameter of
CreateSessionResponse is deprecated in UA 1.04
|
static ApplicationIdentity |
createCertificate(ApplicationDescription applicationDescription,
String organisation,
int keySize,
String... hostNames)
Create a new self-signed Application Identity certificate.
|
static ApplicationIdentity |
createCertificate(ApplicationDescription applicationDescription,
String organisation,
KeyPair issuerKeys,
int keySize,
String... hostNames)
Create a new Application Identity certificate.
|
static ApplicationIdentity |
createCertificate(ApplicationDescription applicationDescription,
String organisation,
KeyPair issuerKeys,
String... hostNames)
Deprecated.
this method depend on static state. Call
createCertificate(ApplicationDescription, String, KeyPair, int, String...)
instead. |
static ApplicationIdentity |
createCertificate(ApplicationDescription applicationDescription,
String organisation,
String... hostNames)
Deprecated.
this method depends on static state. Call
createCertificate(ApplicationDescription, String, int, String...) instead. |
static ApplicationIdentity |
createCertificate(String applicationName,
String organisation,
KeyPair issuerKeys,
String applicationUri,
int keySize,
String... hostNames)
Create the Application Identity certificate.
|
static ApplicationIdentity |
createCertificate(String applicationName,
String organisation,
KeyPair issuerKeys,
String applicationUri,
String... hostNames)
Deprecated.
this method depends on static state. Call
createCertificate(String, String, KeyPair, String, int, String...)
instead. |
static KeyPair |
createHttpsCertificate(ApplicationDescription applicationDecription,
String hostName,
KeyPair issuerKeys)
Deprecated.
this method depends on static state. Call
createHttpsCertificate(ApplicationDescription, String, KeyPair, int)
instead. |
static KeyPair |
createHttpsCertificate(ApplicationDescription applicationDecription,
String hostName,
KeyPair issuerKeys,
int keySize)
/** Create certificate and private key to be used for HTTPS
|
static KeyPair |
createKeyPair(String commonName,
String organisation,
int certificateDays,
KeyPair issuerKeys,
String applicationUri,
int keySize,
String... hostNames)
Create a new Certificate.
|
static KeyPair |
createKeyPair(String commonName,
String organisation,
int certificateDays,
KeyPair issuerKeys,
String applicationUri,
String... hostNames)
Deprecated.
this method depends on static state. Call
createKeyPair(String, String, int, KeyPair, String, int, String...)
instead. |
boolean |
equals(Object obj) |
static String |
getActualHostName()
Returns the hostname with domain (if available).
|
static String |
getActualHostNameWithoutDomain()
Returns the hostname without the domain part.
|
ApplicationDescription |
getApplicationDescription()
The application description defines information about the running application instance.
|
static Set<String> |
getBannedHostnames()
The set of hostnames that we don't want to return from
getActualHostName(). |
protected static File |
getBestFile(File path,
String baseName,
String... extension) |
KeyPair[] |
getCertificates()
The OPC UA Application Instance Certificates of the application.
|
static int |
getDefaultCertificateDays()
The number of days new certificates are valid.
|
KeyPair |
getHttpsCertificate()
The HTTPS Certificate (and private key).
|
String |
getOrganisation()
The organization name used for the application certificates.
|
SignedSoftwareCertificate[] |
getSoftwareCertificates()
Deprecated.
this method returns empty array always as the serverSoftwareCertificates parameter
of CreateSessionResponse is deprecated in UA 1.04
|
int |
hashCode() |
static boolean |
isCacheLocalHostname() |
protected static KeyPair |
loadCertificate(String certType,
String privateKeyPassword,
boolean enableRenew,
File certFile,
File privFile,
boolean usePfx) |
static ApplicationIdentity |
loadOrCreateCertificate(ApplicationDescription applicationDescription,
String organisation,
String privateKeyPassword,
File path,
boolean enableRenew,
String... hostNames)
Load the Application Identity certificate, or create a new one and save it.
|
static ApplicationIdentity |
loadOrCreateCertificate(ApplicationDescription applicationDescription,
String organisation,
String privateKeyPassword,
File path,
KeyPair issuerKeys,
int[] keySizes,
boolean enableRenew,
String... hostNames)
Load the Application Identity certificate, or create a new one and save it.
|
static ApplicationIdentity |
loadOrCreateCertificate(String applicationName,
String organisation,
File certFile,
File privFile,
String privateKeyPassword,
KeyPair issuerKeys,
boolean enableRenew,
String applicationUri,
int keySize,
String... hostNames)
Load the Application Identity certificate, or create a new one and save it.
|
static ApplicationIdentity |
loadOrCreateCertificate(String applicationName,
String organisation,
File certFile,
File privFile,
String privateKeyPassword,
KeyPair issuerKeys,
boolean enableRenew,
String applicationUri,
String... hostNames)
Deprecated.
this method depends on static state. Call
loadOrCreateCertificate(String, String, File, File, String, KeyPair, boolean, String, int, String...)
instead. |
static ApplicationIdentity |
loadOrCreateCertificate(String applicationName,
String organisation,
String privateKeyPassword,
File path,
KeyPair issuerKeys,
int[] keySizes,
boolean enableRenew,
String applicationUri,
String... hostNames)
Load the Application Identity certificate, or create a new one and save it.
|
protected static ApplicationIdentity |
loadOrCreateFromProtectedStore(ApplicationDescription applicationDescription,
String organisation,
String privateKeyPassword,
String keystoreLocation,
String keyStorePassword,
KeyPair issuerKeys,
int keySize,
String... hostNames)
Load the Application Identity certificate from a protected key store, or create a new one and
save it to the store.
|
protected static ApplicationIdentity |
loadOrCreateFromProtectedStore(ApplicationDescription applicationDescription,
String organisation,
String privateKeyPassword,
String keystoreLocation,
String keyStorePassword,
KeyPair issuerKeys,
String... hostNames)
Load the Application Identity certificate from a protected key store, or create a new one and
save it to the store.
|
static KeyPair |
loadOrCreateHttpsCertificate(ApplicationDescription applicationDecription,
String hostName,
String privateKeyPassword,
KeyPair issuerKeys,
File path,
boolean enableRenew)
Deprecated.
this method depends on static state. Call
loadOrCreateHttpsCertificate(ApplicationDescription, String, String, KeyPair, File, boolean, int)
instead. |
static KeyPair |
loadOrCreateHttpsCertificate(ApplicationDescription applicationDecription,
String hostName,
String privateKeyPassword,
KeyPair issuerKeys,
File path,
boolean enableRenew,
int keySize)
Load certificate and private key from applicationName_https.der & .pem - or create ones if they
do not exist
|
static KeyPair |
loadOrCreateIssuerCertificate(String issuerName,
File path,
String privateKeyPassword,
int days,
boolean enableRenew)
Load CA certificate and private key from
|
static KeyPair |
loadOrCreateIssuerCertificate(String issuerName,
File path,
String privateKeyPassword,
int days,
boolean enableRenew,
int keySize)
Load CA certificate and private key from
|
static KeyPair |
loadOrCreateKeyPair(String applicationName,
String organisation,
File certFile,
File privFile,
String privateKeyPassword,
KeyPair caKeys,
boolean enableRenew,
String applicationUri,
int keySize,
String... hostNames) |
static KeyPair |
loadOrCreateKeyPair(String applicationName,
String organisation,
File certFile,
File privFile,
String privateKeyPassword,
KeyPair caKeys,
boolean enableRenew,
String applicationUri,
String... hostNames)
Deprecated.
this method depends on static state. Call
loadOrCreateKeyPair(String, String, File, File, String, KeyPair, boolean, String, int, String...).
instead. |
static String |
replaceHostNameTagWithActualHostName(String string)
Replaces all occurrences of "localhost", "domainname" and "hostname" with the actual hostname
of the computer.
|
protected static void |
saveCertificate(String certType,
KeyPair keys,
File certFile,
File privFile,
String privateKeyPassword,
boolean usePfx) |
static void |
setActualHostName(String hostnameWithDomain)
Calling this method will override the normal hostname resolution used in
getActualHostName(). |
void |
setApplicationDescription(ApplicationDescription applicationDescription)
Define the application description information.
|
void |
setApplicationDescription(ApplicationDescription applicationDescription,
boolean enableValidation)
Define the application description information.
|
static void |
setCacheLocalHostname(boolean cacheLocalHostname)
Set to true to cache the values of
getActualHostName() and
getActualHostNameWithoutDomain() for subsequent calls. |
static void |
setDefaultCertificateDays(int days)
Define the number of days new certificates are valid.
|
void |
setHttpsCertificate(KeyPair httpsCertificate)
The HTTPS Certificate (and private key).
|
void |
setOrganisation(String organisation)
Define the organisation name used for the application
|
decrypt, decrypt, encrypt, getCertificate, getKeys, getPrivateKeypublic static final String CERT_FILE_EXTENSIONS
public ApplicationIdentity()
public ApplicationIdentity(Cert certificate, PrivKey privateKey)
certificate - The application certificateprivateKey - The private keypublic ApplicationIdentity(File certificateFile, File privateKeyFile, String privateKeyPassword) throws IOException, SecureIdentityException
certificateFile - the file containing the user certificateprivateKeyFile - the file containing the user private keyprivateKeyPassword - password used to secure the private keyIOException - if the files cannot be readSecureIdentityException - if the certificate or private key file is not validpublic ApplicationIdentity(File storeLocation, String alias, String privateKeyPassword, String keyStorePassword, String keyStoreType) throws IOException, SecureIdentityException
storeLocation - the pfx-file containing the key storealias - string alias of the key pairprivateKeyPassword - password used to secure the private keykeyStorePassword - password used to secure the key storekeyStoreType - type of the key store, "JKS" and "PKCS12" are supported typesIOException - if the files cannot be readSecureIdentityException - if the certificate or private key file is not validpublic ApplicationIdentity(KeyPair... keyPairs)
keyPairs - array of key pairs.public ApplicationIdentity(URL certificateFile, URL privateKeyFile, String privateKeyPassword) throws IOException, SecureIdentityException
certificateFile - the file containing the user certificateprivateKeyFile - the file containing the user private keyprivateKeyPassword - password used to secure the private keyIOException - if the files cannot be readSecureIdentityException - if the certificate or private key file is not validpublic static ApplicationIdentity createCertificate(ApplicationDescription applicationDescription, String organisation, int keySize, String... hostNames) throws SecureIdentityException
Generates a new public&private key pair and creates a new ApplicationIdentity using it.
applicationDescription - Application name to use in the certificate and also as the file
name base. If the ApplicationUri contains 'localhost' or 'domainname', it will be
converted to the actual host name ( getActualHostName()). If it contains
'hostname', it will be converted to the hostname without domain (
getActualHostNameWithoutDomain())organisation - Organization name to use in the certificate.keySize - the key sizehostNames - alternate host names or IP addresses to add to SubjectAlternativeNameSecureIdentityException - if the certificate could not be generated. Read the cause for
the original exception.public static ApplicationIdentity createCertificate(ApplicationDescription applicationDescription, String organisation, KeyPair issuerKeys, int keySize, String... hostNames) throws SecureIdentityException
Generates a new public&private key pair and creates a new ApplicationIdentity using it.
The certificate is signed with the issuerKeys.
applicationDescription - Application name to use in the certificate and also as the file
name base. If the ApplicationUri contains 'localhost' or 'domainname', it will be
converted to the actual host name ( getActualHostName()). If it contains
'hostname', it will be converted to the hostname without domain (
getActualHostNameWithoutDomain())organisation - Organization name to use in the certificate.issuerKeys - the certificate and private key of the issuer, to be used for signing the new
certificatekeySize - the key sizehostNames - alternate host names or IP addresses to add to SubjectAlternativeNameSecureIdentityException - if the certificate could not be generated. Read the cause for
the original exception.@Deprecated public static ApplicationIdentity createCertificate(ApplicationDescription applicationDescription, String organisation, KeyPair issuerKeys, String... hostNames) throws SecureIdentityException
createCertificate(ApplicationDescription, String, KeyPair, int, String...)
instead.Generates a new public&private key pair and creates a new ApplicationIdentity using it.
The certificate is signed with the issuerKeys.
applicationDescription - Application name to use in the certificate and also as the file
name base. If the ApplicationUri contains 'localhost' or 'domainname', it will be
converted to the actual host name ( getActualHostName()). If it contains
'hostname', it will be converted to the hostname without domain (
getActualHostNameWithoutDomain())organisation - Organization name to use in the certificate.issuerKeys - the certificate and private key of the issuer, to be used for signing the new
certificatehostNames - alternate host names or IP addresses to add to SubjectAlternativeNameSecureIdentityException - if the certificate could not be generated. Read the cause for
the original exception.@Deprecated public static ApplicationIdentity createCertificate(ApplicationDescription applicationDescription, String organisation, String... hostNames) throws SecureIdentityException
createCertificate(ApplicationDescription, String, int, String...) instead.Generates a new public&private key pair and creates a new ApplicationIdentity using it.
applicationDescription - Application name to use in the certificate and also as the file
name base. If the ApplicationUri contains 'localhost' or 'domainname', it will be
converted to the actual host name ( getActualHostName()). If it contains
'hostname', it will be converted to the hostname without domain (
getActualHostNameWithoutDomain())organisation - Organization name to use in the certificate.hostNames - alternate host names or IP addresses to add to SubjectAlternativeNameSecureIdentityException - if the certificate could not be generated. Read the cause for
the original exception.public static ApplicationIdentity createCertificate(String applicationName, String organisation, KeyPair issuerKeys, String applicationUri, int keySize, String... hostNames) throws SecureIdentityException
Generates a new public&private key pair and creates a new ApplicationIdentity using it.
applicationName - Application name to use in the certificate and also as the file name
base. If the ApplicationUri contains 'localhost' or 'domainname', it will be converted
to the actual host name ( getActualHostName()). If it contains 'hostname', it
will be converted to the hostname without domain (
getActualHostNameWithoutDomain())organisation - Organization name to use in the certificate.issuerKeys - the certificate and private key of the issuer, to be used for signing the new
certificateapplicationUri - The application URI to use for SubjectAlternativeNamekeySize - the key sizehostNames - alternate host names or IP addresses to add to SubjectAlternativeNameSecureIdentityException - if the certificate could not be generated. Read the cause for
the original exception.@Deprecated public static ApplicationIdentity createCertificate(String applicationName, String organisation, KeyPair issuerKeys, String applicationUri, String... hostNames) throws SecureIdentityException
createCertificate(String, String, KeyPair, String, int, String...)
instead.Generates a new public&private key pair and creates a new ApplicationIdentity using it.
applicationName - Application name to use in the certificate and also as the file name
base. If the ApplicationUri contains 'localhost' or 'domainname', it will be converted
to the actual host name ( getActualHostName()). If it contains 'hostname', it
will be converted to the hostname without domain (
getActualHostNameWithoutDomain())organisation - Organization name to use in the certificate.issuerKeys - the certificate and private key of the issuer, to be used for signing the new
certificateapplicationUri - The application URI to use for SubjectAlternativeNamehostNames - alternate host names or IP addresses to add to SubjectAlternativeNameSecureIdentityException - if the certificate could not be generated. Read the cause for
the original exception.@Deprecated public static KeyPair createHttpsCertificate(ApplicationDescription applicationDecription, String hostName, KeyPair issuerKeys) throws GeneralSecurityException, IOException
createHttpsCertificate(ApplicationDescription, String, KeyPair, int)
instead.applicationDescription - Application name to use in the certificate and also as the file
name base.hostName - The hostname to use for the certificate subject. The clients may verify the
hostname that it matches the URL of the server.issuerKeys - The certificate and private key of the issuer, to be used for signing the new
certificateGeneralSecurityExceptionIOExceptionpublic static KeyPair createHttpsCertificate(ApplicationDescription applicationDecription, String hostName, KeyPair issuerKeys, int keySize) throws GeneralSecurityException, IOException
applicationDescription - Application name to use in the certificate and also as the file
name base.hostName - The hostname to use for the certificate subject. The clients may verify the
hostname that it matches the URL of the server.issuerKeys - The certificate and private key of the issuer, to be used for signing the new
certificateGeneralSecurityExceptionIOExceptionpublic static KeyPair createKeyPair(String commonName, String organisation, int certificateDays, KeyPair issuerKeys, String applicationUri, int keySize, String... hostNames) throws SecureIdentityException
commonName - The value for the Common Name field of the certificateorganisation - The value for the Common Name field of the certificatecertificateDays - Number of days that the certificate is to be validissuerKeys - the keys of the optional Certificate Authority to use for signing the
certificateapplicationUri - The application URI to use for SubjectAlternativeNamekeySize - the key sizehostNames - alternate host names or IP addresses to add to SubjectAlternativeNameSecureIdentityException - if the certificate could not be created@Deprecated public static KeyPair createKeyPair(String commonName, String organisation, int certificateDays, KeyPair issuerKeys, String applicationUri, String... hostNames) throws SecureIdentityException
createKeyPair(String, String, int, KeyPair, String, int, String...)
instead.commonName - The value for the Common Name field of the certificateorganisation - The value for the Common Name field of the certificatecertificateDays - Number of days that the certificate is to be validissuerKeys - the keys of the optional Certificate Authority to use for signing the
certificateapplicationUri - The application URI to use for SubjectAlternativeNamehostNames - alternate host names or IP addresses to add to SubjectAlternativeNameSecureIdentityException - if the certificate could not be createdpublic static String getActualHostName()
setCacheLocalHostname(boolean) is true,
which by default is.
The hostnames that are included in getBannedHostnames() are ignored if they would be
returned. Instead the result of OSUtil.getHostNameWithDomain() is used. This is done
basically to work around the 'host.docker.internal' hostname alias appearing in Windows with
Docker installation, which overrides the real hostname of the computer.
public static String getActualHostNameWithoutDomain()
getActualHostName() and removing everything after the first dot. If there is no domain
part, just returns the whole hostname. Calling this method the first time may be slow,
subsequent calls use cached value, if setCacheLocalHostname(boolean) is true, which by
default is.public static Set<String> getBannedHostnames()
getActualHostName().
This set is used to work around the 'host.docker.internal' hostname alias appearing in Windows with Docker installation, which overrides the real hostname of the computer. Therefore the list includes just 'host.docker.internal' by default, but if you need to ban other names, you can add them to the set. Or if you still wish to see this hostname, you can remove it from the set.
public static int getDefaultCertificateDays()
public static boolean isCacheLocalHostname()
setCacheLocalHostname(boolean),
setActualHostName(String)public static ApplicationIdentity loadOrCreateCertificate(ApplicationDescription applicationDescription, String organisation, String privateKeyPassword, File path, boolean enableRenew, String... hostNames) throws SecureIdentityException, IOException
In the first run this method creates public&private key pair and saves them to files. In other runs the key pairs are loaded from files.
applicationDescription - Application name to use in the certificate and also as the file
name base.organisation - Organization name to use in the certificate.privateKeyPassword - The password for private keypath - Optional path to the filesenableRenew - Enable renewing the certificate if it has expired.hostNames - alternate host names or IP addresses to add to SubjectAlternativeNameSecureIdentityException - if the certificate could not be loaded or generated. Read the
cause for the original exception.IOException - if the certificate files cannot be read or created.public static ApplicationIdentity loadOrCreateCertificate(ApplicationDescription applicationDescription, String organisation, String privateKeyPassword, File path, KeyPair issuerKeys, int[] keySizes, boolean enableRenew, String... hostNames) throws SecureIdentityException, IOException
In the first run this method creates public&private key pair and saves them to files. In other runs the key pairs are loaded from files.
applicationDescription - Application name to use in the certificate and also as the file
name base.organisation - Organization name to use in the certificate.privateKeyPassword - The password for private keypath - Optional path to the filesissuerKeys - the certificate and private key of the issuer, to be used for signing the new
certificatekeySizes - an array of key sizes to use for the identity. A separate certificate will be
created with each size. The various key sizes may be necessary, depending on which
SecurityPolicy alternatives are enabled by the application.enableRenew - Enable renewing the certificate if it has expired.hostNames - alternate host names or IP addresses to add to SubjectAlternativeNameSecureIdentityException - if the certificate could not be loaded or generated. Read the
cause for the original exception.IOException - if the certificate files cannot be read or created.public static ApplicationIdentity loadOrCreateCertificate(String applicationName, String organisation, File certFile, File privFile, String privateKeyPassword, KeyPair issuerKeys, boolean enableRenew, String applicationUri, int keySize, String... hostNames) throws SecureIdentityException, IOException
In the first run this method creates public&private key pair and saves them to files. In other runs the key pairs are loaded from files.
If the certificate expires, it is automatically renewed, if enableRenew is true.
The key size will be the default, as defined by CertificateUtils.getKeySize().
applicationName - Application name to use in the certificate and also as the file name
base.organisation - Organization name to use in the certificate.certFile - The file used to store the certificate. The certificate is saved in binary DER
formatprivFile - The file used to store the private key. The key is saved in PEM format, but can
be read in PFX or raw binary as well, depending on the actual format of the file.privateKeyPassword - The password for private keyissuerKeys - The certificate and private key of the issuer, to be used for signing the new
certificate. If null, a self-signed certificate is created.enableRenew - Enable renewing the certificate if it has expired.applicationUri - The application URI to use for SubjectAlternativeNamekeySize - the key sizehostNames - Alternate host names or IP addresses to add to SubjectAlternativeNameSecureIdentityException - if the certificate could not be loaded or generated. Read the
cause for the original exception.IOException - if the certificate files cannot be loaded or created.@Deprecated public static ApplicationIdentity loadOrCreateCertificate(String applicationName, String organisation, File certFile, File privFile, String privateKeyPassword, KeyPair issuerKeys, boolean enableRenew, String applicationUri, String... hostNames) throws SecureIdentityException, IOException
loadOrCreateCertificate(String, String, File, File, String, KeyPair, boolean, String, int, String...)
instead.In the first run this method creates public&private key pair and saves them to files. In other runs the key pairs are loaded from files.
If the certificate expires, it is automatically renewed, if enableRenew is true.
The key size will be the default, as defined by CertificateUtils.getKeySize().
applicationName - Application name to use in the certificate and also as the file name
base.organisation - Organization name to use in the certificate.certFile - The file used to store the certificate. The certificate is saved in binary DER
formatprivFile - The file used to store the private key. The key is saved in PEM format, but can
be read in PFX or raw binary as well, depending on the actual format of the file.privateKeyPassword - The password for private keyissuerKeys - The certificate and private key of the issuer, to be used for signing the new
certificate. If null, a self-signed certificate is created.enableRenew - Enable renewing the certificate if it has expired.applicationUri - The application URI to use for SubjectAlternativeNamehostNames - Alternate host names or IP addresses to add to SubjectAlternativeNameSecureIdentityException - if the certificate could not be loaded or generated. Read the
cause for the original exception.IOException - if the certificate files cannot be loaded or created.public static ApplicationIdentity loadOrCreateCertificate(String applicationName, String organisation, String privateKeyPassword, File path, KeyPair issuerKeys, int[] keySizes, boolean enableRenew, String applicationUri, String... hostNames) throws SecureIdentityException, IOException
In the first run this method creates public&private key pair and saves them to files. In other runs the key pairs are loaded from files.
applicationName - Application name to use in the certificate and also as the file name
base.organisation - Organization name to use in the certificate.privateKeyPassword - The password for private keypath - Optional path to the filesissuerKeys - The certificate and private key of the issuer, to be used for signing the new
certificate. If null, a self-signed certificate is created.keySizes - An array of key sizes to use for the identity. A separate certificate will be
created with each size. The various key sizes may be necessary, depending on which
SecurityPolicy alternatives are enabled by the application. Entry may be 0, in
which case the default KeySize is used - and the fileName to look for is not appended
with the keySize. If the keySizes is omitted (null or empty), the default key size, as
defined by CertificateUtils.DEFAULT_KEY_SIZE, is used.enableRenew - Enable renewing the certificate if it has expired.applicationUri - The application URI to use for SubjectAlternativeNamehostNames - Alternate host names or IP addresses to add to SubjectAlternativeNameSecureIdentityException - if the certificate could not be loaded or generated. Read the
cause for the original exception.IOException - if the certificate files cannot be loaded or created.@Deprecated public static KeyPair loadOrCreateHttpsCertificate(ApplicationDescription applicationDecription, String hostName, String privateKeyPassword, KeyPair issuerKeys, File path, boolean enableRenew) throws IOException, SecureIdentityException
loadOrCreateHttpsCertificate(ApplicationDescription, String, String, KeyPair, File, boolean, int)
instead.applicationDescription - Application name to use in the certificate and also as the file
name base.hostName - The hostname to use for the certificate subject. The clients may verify the
hostname that it matches the URL of the server.path - Optional path to the filesissuerKeys - The certificate and private key of the issuer, to be used for signing the new
certificateenableRenew - Enable renewing the certificate if it has expired.IOException - if the certificate or private key cannot be stored in the defined path.SecureIdentityException - if the certificate creation fails.public static KeyPair loadOrCreateHttpsCertificate(ApplicationDescription applicationDecription, String hostName, String privateKeyPassword, KeyPair issuerKeys, File path, boolean enableRenew, int keySize) throws IOException, SecureIdentityException
applicationDescription - Application name to use in the certificate and also as the file
name base.hostName - The hostname to use for the certificate subject. The clients may verify the
hostname that it matches the URL of the server.path - Optional path to the filesissuerKeys - The certificate and private key of the issuer, to be used for signing the new
certificateenableRenew - Enable renewing the certificate if it has expired.keySize - The key sizeIOException - if the certificate or private key cannot be stored in the defined path.SecureIdentityException - if the certificate creation fails.public static KeyPair loadOrCreateIssuerCertificate(String issuerName, File path, String privateKeyPassword, int days, boolean enableRenew) throws IOException, SecureIdentityException
issuerName - The name of the issuer to use as the Subject for the certificate and file
names.path - optional path to the filesprivateKeyPassword - the password used to protect the private key filedays - number of days the certificate will be validenableRenew - IOExceptionSecureIdentityExceptionpublic static KeyPair loadOrCreateIssuerCertificate(String issuerName, File path, String privateKeyPassword, int days, boolean enableRenew, int keySize) throws IOException, SecureIdentityException
issuerName - The name of the issuer to use as the Subject for the certificate and file
names.path - optional path to the filesprivateKeyPassword - the password used to protect the private key filedays - number of days the certificate will be validenableRenew - keySize - IOExceptionSecureIdentityExceptionpublic static KeyPair loadOrCreateKeyPair(String applicationName, String organisation, File certFile, File privFile, String privateKeyPassword, KeyPair caKeys, boolean enableRenew, String applicationUri, int keySize, String... hostNames) throws IOException, SecureIdentityException
IOExceptionSecureIdentityException@Deprecated public static KeyPair loadOrCreateKeyPair(String applicationName, String organisation, File certFile, File privFile, String privateKeyPassword, KeyPair caKeys, boolean enableRenew, String applicationUri, String... hostNames) throws IOException, SecureIdentityException
loadOrCreateKeyPair(String, String, File, File, String, KeyPair, boolean, String, int, String...).
instead.IOExceptionSecureIdentityExceptionpublic static String replaceHostNameTagWithActualHostName(String string)
getActualHostName() is used to replace "localhost" and "domainname".
"hostname" is replaced with getActualHostNameWithoutDomain().string - the string value to modifypublic static void setActualHostName(String hostnameWithDomain)
getActualHostName(). The value will be stored regardless of
setCacheLocalHostname(boolean). The hostname should be the fully qualified domain
name, if that is available. This method should be called before calling any other method of the
SDK that might use the hostname.setActualHostName(String)public static void setCacheLocalHostname(boolean cacheLocalHostname)
getActualHostName() and
getActualHostNameWithoutDomain() for subsequent calls. Default value is true.public static void setDefaultCertificateDays(int days)
protected static KeyPair loadCertificate(String certType, String privateKeyPassword, boolean enableRenew, File certFile, File privFile, boolean usePfx) throws SecureIdentityException
SecureIdentityExceptionprotected static ApplicationIdentity loadOrCreateFromProtectedStore(ApplicationDescription applicationDescription, String organisation, String privateKeyPassword, String keystoreLocation, String keyStorePassword, KeyPair issuerKeys, int keySize, String... hostNames) throws IOException, SecureIdentityException
applicationDescription - Application description to use in the certificate and also as the
file name base. Must not be nullorganisation - Organization name to use in the certificate.privateKeyPassword - keystoreLocation - keyStorePassword - issuerKeys - keySize - hostNames - IOException - if the key store cannot be openedSecureIdentityException - if the certificate could not be generated. Read the cause for
the original exception.protected static ApplicationIdentity loadOrCreateFromProtectedStore(ApplicationDescription applicationDescription, String organisation, String privateKeyPassword, String keystoreLocation, String keyStorePassword, KeyPair issuerKeys, String... hostNames) throws IOException, SecureIdentityException
applicationDescription - Application description to use in the certificate and also as the
file name base. Must not be nullorganisation - Organization name to use in the certificate.privateKeyPassword - keystoreLocation - keyStorePassword - IOException - if the key store cannot be openedSecureIdentityException - if the certificate could not be generated. Read the cause for
the original exception.protected static void saveCertificate(String certType, KeyPair keys, File certFile, File privFile, String privateKeyPassword, boolean usePfx) throws IOException, GeneralSecurityException
IOExceptionGeneralSecurityException@Deprecated public void addSoftwareCertificates(SignedSoftwareCertificate[] softwareCertificates)
softwareCertificates - public boolean equals(Object obj)
equals in class SecureIdentitypublic ApplicationDescription getApplicationDescription()
public KeyPair[] getCertificates()
public KeyPair getHttpsCertificate()
loadOrCreateHttpsCertificate(ApplicationDescription, String, String, KeyPair, File, boolean)
.public String getOrganisation()
@Deprecated public SignedSoftwareCertificate[] getSoftwareCertificates()
public int hashCode()
hashCode in class SecureIdentitypublic void setApplicationDescription(ApplicationDescription applicationDescription)
applicationDescription - the application description information.public void setApplicationDescription(ApplicationDescription applicationDescription, boolean enableValidation)
applicationDescription - the application description information.enableValidation - if set, 'localhost', 'domainname' or 'hostname' may be replaced with
the actual hostname. 'hostname' will be replaced without the domain part of the
hostname. The other ones, will use the fully qualified hostname.public void setHttpsCertificate(KeyPair httpsCertificate)
loadOrCreateHttpsCertificate(ApplicationDescription, String, String, KeyPair, File, boolean)
.httpsCertificate - public void setOrganisation(String organisation)
organisation - Copyright © 2026. All rights reserved.