CertMgr Class
Properties Methods Events Config Settings Errors
The CertMgr class is used to create, read, and manage certificates.
Syntax
CertMgr
Remarks
The class methods, such as ListCertificateStores or ListStoreCertificates, are used to list certificate stores and certificates. The corresponding lists are returned through the StoreList and CertList events. Encoded certificates are provided through the events.
You can load a certificate by setting the Cert property of the class. Then you can get information about the certificate through the corresponding fields of the Cert property (described below).
The CertSubject, CertSerialNumber, and CertIssuer properties identify the certificate. The CertEffectiveDate and CertExpirationDate show the time boundaries of the certificate.
CertPublicKey, CertPublicKeyAlgorithm, CertPublicKeyLength, and CertVersion provide information about the certificate keys and the certificate format (version).
CertUsageFlags specifies the intended usage of the certificate. The CertUsage property provides a text description of these flags.
Property List
The following is the full list of the properties of the class with short descriptions. Click on the links for further details.
CertEffectiveDate | This is the date on which this certificate becomes valid. |
CertEncoded | This is the certificate (PEM/base64 encoded). |
CertExpirationDate | This is the date the certificate expires. |
CertExtendedKeyUsage | This is a comma-delimited list of extended key usage identifiers. |
CertFingerprint | This is the hex-encoded, 16-byte MD5 fingerprint of the certificate. |
CertFingerprintSHA1 | This is the hex-encoded, 20-byte SHA-1 fingerprint of the certificate. |
CertFingerprintSHA256 | This is the hex-encoded, 32-byte SHA-256 fingerprint of the certificate. |
CertIssuer | This is the issuer of the certificate. |
CertKeyPassword | This is the password for the certificate's private key (if any). |
CertPrivateKey | This is the private key of the certificate (if available). |
CertPrivateKeyAvailable | This property shows whether a PrivateKey is available for the selected certificate. |
CertPrivateKeyContainer | This is the name of the PrivateKey container for the certificate (if available). |
CertPublicKey | This is the public key of the certificate. |
CertPublicKeyAlgorithm | This property contains the textual description of the certificate's public key algorithm. |
CertPublicKeyLength | This is the length of the certificate's public key (in bits). |
CertSerialNumber | This is the serial number of the certificate encoded as a string. |
CertSignatureAlgorithm | The property contains the text description of the certificate's signature algorithm. |
CertSubject | This is the subject of the certificate used for client authentication. |
CertSubjectAltNames | This property contains comma-separated lists of alternative subject names for the certificate. |
CertThumbprintMD5 | This property contains the MD5 hash of the certificate. |
CertThumbprintSHA1 | This property contains the SHA-1 hash of the certificate. |
CertThumbprintSHA256 | This property contains the SHA-256 hash of the certificate. |
CertUsage | This property contains the text description of UsageFlags . |
CertUsageFlags | This property contains the flags that show intended use for the certificate. |
CertVersion | This property contains the certificate's version number. |
CertExtensionCount | The number of records in the CertExtension arrays. |
CertExtensionCritical | This property specifies whether or not the extension is defined as critical. |
CertExtensionOID | This property contains the ASN. |
CertExtensionValue | This property contains the raw value of the certificate extension. |
CertStore | This is the certificate store to search for certificates. |
CertStorePassword | This is the password for the certificate store (if any). |
CertStoreType | This is the type of certificate store for CertStore . |
ExportedCert | This is the exported certificate string. |
ExportFormat | This is the format to which the certificate is exported. |
ExportPrivateKey | This controls whether to export the private key. |
Method List
The following is the full list of the methods of the class with short descriptions. Click on the links for further details.
Config | Sets or retrieves a configuration setting. |
CreateCertificate | This method creates a new self-signed certificate in the current store. |
CreateKey | This method creates a new keyset associated with the provided name. |
DeleteCertificate | This method deletes the currently selected certificate from the store. |
DeleteKey | This method deletes the keyset associated with the provided name. |
ExportCertificate | This method exports the currently selected certificate. |
GenerateCSR | This method generates a new Certificate Signing Request (CSR) to be sent to a signing authority. |
ImportCertificate | This method imports a certificate from a file into the current certificate store. |
ImportSignedCSR | This method mports a signed Certificate Signing Request (CSR). |
IssueCertificate | This creates a new certificate in the current store and is signed by the selected certificate. |
ListCertificateStores | This lists the certificate stores. |
ListKeys | This lists the keysets in a Cryptographic Service Provider (CSP). |
ListMachineStores | This lists the machine certificate stores. |
ListStoreCertificates | This lists the certificates in a store. |
ReadCertificate | This loads a certificate from a file. |
ReadCSR | This reads a Certificate Signing Request (CSR). |
Reset | This resets all certificate properties to their default values. |
SaveCertificate | This method saves the currently selected public certificate to a file. |
ShowCertificateChain | This shows the certificate chain. |
SignCSR | This creates a signed certificate from a Certificate Signing Request (CSR). |
Event List
The following is the full list of the events fired by the class with short descriptions. Click on the links for further details.
CertChain | This event shows the certificate chain for the certificate (see the ShowCertificateChain method). |
CertList | This event lists the certificates in a store (see the ListStoreCertificates method). |
Error | Information about errors during data delivery. |
KeyList | This lists the keysets in a Cryptographic Service Provider (CSP); see the ListKeys method. |
Log | This event fires once for each log message. |
StoreList | This lists the system certificate stores (see the ListCertificateStores and ListMachineStores methods). |
Config Settings
The following is a list of config settings for the class with short descriptions. Click on the links for further details.
CertComment | A comment to include in a saved certificate. |
CertCustomExtensionCount | The number of records in the CertCustomExtension arrays. |
CertCustomExtensionCritical[i] | Whether or not the extension is defined as critical. |
CertCustomExtensionOID[i] | The ASN of the extension at index 'i'. |
CertCustomExtensionValue[i] | The raw value of the extension at index 'i'. |
CertExtendedKeyUsage | The extended key usage of the certificate. |
CertKeyLength | The public key length for created certificates and keys. |
CertKeyType | The types of keys created for new certificates. |
CertPublicKeyAlgorithm | The public key algorithm used when a certificate is created. |
CertSignatureAlgorithm | The signature algorithm used when creating certificates. |
CertSubjectAltNames | Subject Alternative Names for creating or issuing certificates. |
CertThumbprint | The thumbprint of the certificate to be loaded. |
CertUsageFlags | Sets the flags indicating the usage of the created certificate. |
CertValidityOffset | The number of days until the certificate becomes valid. |
CertValidityTime | The validity period for the certificate. |
CreatedKey | The PKCS8 formatted private and public key pair created after calling CreateKey. |
CSP | The Cryptographic Service Provider. |
CSRIgnoredExtensions | Extensions to be ignorned when signing a CSR. |
CSRKey | The PKCS8 formatted private key to use when generating a CSR. |
EncodeExportedCert | Whether the certificate being exported to a string is encoded. |
ImportCertAction | Specified the action to take if a matching certificate or a link to a matching certificate already exists. |
ImportCertStoreType | The type of certificate store being specified for import. |
JWKAlgorithm | The JWK algorithm. |
JWKExportX5C | Whether to export a certificate chain to the x5c parameter. |
JWKKeyId | The JWK key Id. |
JWKKeyOps | The JWK intended key operations list. |
JWKUse | The JWK use parameter value. |
KeyFormat | How the public and private key are formatted. |
LogLevel | The level of detail that is logged. |
ReplaceKey | Whether or not to replace an existing key when creating a new key. |
RequestSubjectAltNames | Subject Alternative Names for a Certificate Signing Request. |
X509Algorithm | Public Key Algorithm OID. |
X509SignatureAlgorithm | Signature Algorithm OID. |
BuildInfo | Information about the product's build. |
CodePage | The system code page used for Unicode to Multibyte translations. |
LicenseInfo | Information about the current license. |
MaskSensitive | Whether sensitive data is masked in log messages. |
ProcessIdleEvents | Whether the class uses its internal event loop to process events when the main thread is idle. |
SelectWaitMillis | The length of time in milliseconds the class will wait when DoEvents is called if there are no events to process. |
UseInternalSecurityAPI | Tells the class whether or not to use the system security libraries or an internal implementation. |
CertEffectiveDate Property (CertMgr Class)
This is the date on which this certificate becomes valid.
Syntax
ANSI (Cross Platform) char* GetCertEffectiveDate(); Unicode (Windows) LPWSTR GetCertEffectiveDate();
char* ipworksiot_certmgr_getcerteffectivedate(void* lpObj);
QString GetCertEffectiveDate();
Default Value
""
Remarks
This is the date on which this certificate becomes valid. Before this date, it is not valid. The following example illustrates the format of an encoded date:
23-Jan-2000 15:00:00.
This property is read-only.
Data Type
String
CertEncoded Property (CertMgr Class)
This is the certificate (PEM/base64 encoded).
Syntax
ANSI (Cross Platform) int GetCertEncoded(char* &lpCertEncoded, int &lenCertEncoded);
int SetCertEncoded(const char* lpCertEncoded, int lenCertEncoded); Unicode (Windows) INT GetCertEncoded(LPSTR &lpCertEncoded, INT &lenCertEncoded);
INT SetCertEncoded(LPCSTR lpCertEncoded, INT lenCertEncoded);
int ipworksiot_certmgr_getcertencoded(void* lpObj, char** lpCertEncoded, int* lenCertEncoded);
int ipworksiot_certmgr_setcertencoded(void* lpObj, const char* lpCertEncoded, int lenCertEncoded);
QByteArray GetCertEncoded();
int SetCertEncoded(QByteArray qbaCertEncoded);
Default Value
""
Remarks
This is the certificate (PEM/Base64 encoded). This property is used to assign a specific certificate. The CertStore and CertSubject properties also may be used to specify a certificate.
When CertEncoded is set, a search is initiated in the current CertStore for the private key of the certificate. If the key is found, CertSubject is updated to reflect the full subject of the selected certificate; otherwise, CertSubject is set to an empty string.
This property is not available at design time.
Data Type
Binary String
CertExpirationDate Property (CertMgr Class)
This is the date the certificate expires.
Syntax
ANSI (Cross Platform) char* GetCertExpirationDate(); Unicode (Windows) LPWSTR GetCertExpirationDate();
char* ipworksiot_certmgr_getcertexpirationdate(void* lpObj);
QString GetCertExpirationDate();
Default Value
""
Remarks
This is the date the certificate expires. After this date, the certificate will no longer be valid. The following example illustrates the format of an encoded date:
23-Jan-2001 15:00:00.
This property is read-only.
Data Type
String
CertExtendedKeyUsage Property (CertMgr Class)
This is a comma-delimited list of extended key usage identifiers.
Syntax
ANSI (Cross Platform) char* GetCertExtendedKeyUsage();
int SetCertExtendedKeyUsage(const char* lpszCertExtendedKeyUsage); Unicode (Windows) LPWSTR GetCertExtendedKeyUsage();
INT SetCertExtendedKeyUsage(LPCWSTR lpszCertExtendedKeyUsage);
char* ipworksiot_certmgr_getcertextendedkeyusage(void* lpObj);
int ipworksiot_certmgr_setcertextendedkeyusage(void* lpObj, const char* lpszCertExtendedKeyUsage);
QString GetCertExtendedKeyUsage();
int SetCertExtendedKeyUsage(QString qsCertExtendedKeyUsage);
Default Value
""
Remarks
This is a comma-delimited list of extended key usage identifiers. These are the same as ASN.1 object identifiers (OIDs).
Data Type
String
CertFingerprint Property (CertMgr Class)
This is the hex-encoded, 16-byte MD5 fingerprint of the certificate.
Syntax
ANSI (Cross Platform) char* GetCertFingerprint(); Unicode (Windows) LPWSTR GetCertFingerprint();
char* ipworksiot_certmgr_getcertfingerprint(void* lpObj);
QString GetCertFingerprint();
Default Value
""
Remarks
This is the hex-encoded, 16-byte MD5 fingerprint of the certificate. This property is primarily used for keys which do not have a corresponding X.509 public certificate, such as PEM keys that only contain a private key. It is commonly used for SSH keys.
The following example illustrates the format: bc:2a:72:af:fe:58:17:43:7a:5f:ba:5a:7c:90:f7:02
This property is read-only.
Data Type
String
CertFingerprintSHA1 Property (CertMgr Class)
This is the hex-encoded, 20-byte SHA-1 fingerprint of the certificate.
Syntax
ANSI (Cross Platform) char* GetCertFingerprintSHA1(); Unicode (Windows) LPWSTR GetCertFingerprintSHA1();
char* ipworksiot_certmgr_getcertfingerprintsha1(void* lpObj);
QString GetCertFingerprintSHA1();
Default Value
""
Remarks
This is the hex-encoded, 20-byte SHA-1 fingerprint of the certificate. This property is primarily used for keys which do not have a corresponding X.509 public certificate, such as PEM keys that only contain a private key. It is commonly used for SSH keys.
The following example illustrates the format: 30:7b:fa:38:65:83:ff:da:b4:4e:07:3f:17:b8:a4:ed:80:be:ff:84
This property is read-only.
Data Type
String
CertFingerprintSHA256 Property (CertMgr Class)
This is the hex-encoded, 32-byte SHA-256 fingerprint of the certificate.
Syntax
ANSI (Cross Platform) char* GetCertFingerprintSHA256(); Unicode (Windows) LPWSTR GetCertFingerprintSHA256();
char* ipworksiot_certmgr_getcertfingerprintsha256(void* lpObj);
QString GetCertFingerprintSHA256();
Default Value
""
Remarks
This is the hex-encoded, 32-byte SHA-256 fingerprint of the certificate. This property is primarily used for keys which do not have a corresponding X.509 public certificate, such as PEM keys that only contain a private key. It is commonly used for SSH keys.
The following example illustrates the format: 6a:80:5c:33:a9:43:ea:b0:96:12:8a:64:96:30:ef:4a:8a:96:86:ce:f4:c7:be:10:24:8e:2b:60:9e:f3:59:53
This property is read-only.
Data Type
String
CertIssuer Property (CertMgr Class)
This is the issuer of the certificate.
Syntax
ANSI (Cross Platform) char* GetCertIssuer(); Unicode (Windows) LPWSTR GetCertIssuer();
char* ipworksiot_certmgr_getcertissuer(void* lpObj);
QString GetCertIssuer();
Default Value
""
Remarks
This is the issuer of the certificate. This property contains a string representation of the name of the issuing authority for the certificate.
This property is read-only.
Data Type
String
CertKeyPassword Property (CertMgr Class)
This is the password for the certificate's private key (if any).
Syntax
ANSI (Cross Platform) char* GetCertKeyPassword();
int SetCertKeyPassword(const char* lpszCertKeyPassword); Unicode (Windows) LPWSTR GetCertKeyPassword();
INT SetCertKeyPassword(LPCWSTR lpszCertKeyPassword);
char* ipworksiot_certmgr_getcertkeypassword(void* lpObj);
int ipworksiot_certmgr_setcertkeypassword(void* lpObj, const char* lpszCertKeyPassword);
QString GetCertKeyPassword();
int SetCertKeyPassword(QString qsCertKeyPassword);
Default Value
""
Remarks
This is the password for the certificate's private key (if any).
Some certificate stores may individually protect certificates' private keys, separate from the standard protection offered by the CertStorePassword. CertKeyPassword. This field can be used to read such password-protected private keys.
Note: this property defaults to the value of CertStorePassword. To clear it, you must set the property to the empty string (""). It can be set at any time, but when the private key's password is different from the store's password, then it must be set before calling CertPrivateKey.
Data Type
String
CertPrivateKey Property (CertMgr Class)
This is the private key of the certificate (if available).
Syntax
ANSI (Cross Platform) char* GetCertPrivateKey(); Unicode (Windows) LPWSTR GetCertPrivateKey();
char* ipworksiot_certmgr_getcertprivatekey(void* lpObj);
QString GetCertPrivateKey();
Default Value
""
Remarks
This is the private key of the certificate (if available). The key is provided as PEM/Base64-encoded data.
Note: The CertPrivateKey may be available but not exportable. In this case, CertPrivateKey returns an empty string.
This property is read-only.
Data Type
String
CertPrivateKeyAvailable Property (CertMgr Class)
This property shows whether a PrivateKey is available for the selected certificate.
Syntax
ANSI (Cross Platform) int GetCertPrivateKeyAvailable(); Unicode (Windows) BOOL GetCertPrivateKeyAvailable();
int ipworksiot_certmgr_getcertprivatekeyavailable(void* lpObj);
bool GetCertPrivateKeyAvailable();
Default Value
FALSE
Remarks
This property shows whether a CertPrivateKey is available for the selected certificate. If CertPrivateKeyAvailable is True, the certificate may be used for authentication purposes (e.g., server authentication).
This property is read-only.
Data Type
Boolean
CertPrivateKeyContainer Property (CertMgr Class)
This is the name of the PrivateKey container for the certificate (if available).
Syntax
ANSI (Cross Platform) char* GetCertPrivateKeyContainer(); Unicode (Windows) LPWSTR GetCertPrivateKeyContainer();
char* ipworksiot_certmgr_getcertprivatekeycontainer(void* lpObj);
QString GetCertPrivateKeyContainer();
Default Value
""
Remarks
This is the name of the CertPrivateKey container for the certificate (if available). This functionality is available only on Windows platforms.
This property is read-only.
Data Type
String
CertPublicKey Property (CertMgr Class)
This is the public key of the certificate.
Syntax
ANSI (Cross Platform) char* GetCertPublicKey(); Unicode (Windows) LPWSTR GetCertPublicKey();
char* ipworksiot_certmgr_getcertpublickey(void* lpObj);
QString GetCertPublicKey();
Default Value
""
Remarks
This is the public key of the certificate. The key is provided as PEM/Base64-encoded data.
This property is read-only.
Data Type
String
CertPublicKeyAlgorithm Property (CertMgr Class)
This property contains the textual description of the certificate's public key algorithm.
Syntax
ANSI (Cross Platform) char* GetCertPublicKeyAlgorithm();
int SetCertPublicKeyAlgorithm(const char* lpszCertPublicKeyAlgorithm); Unicode (Windows) LPWSTR GetCertPublicKeyAlgorithm();
INT SetCertPublicKeyAlgorithm(LPCWSTR lpszCertPublicKeyAlgorithm);
char* ipworksiot_certmgr_getcertpublickeyalgorithm(void* lpObj);
int ipworksiot_certmgr_setcertpublickeyalgorithm(void* lpObj, const char* lpszCertPublicKeyAlgorithm);
QString GetCertPublicKeyAlgorithm();
int SetCertPublicKeyAlgorithm(QString qsCertPublicKeyAlgorithm);
Default Value
""
Remarks
This property contains the textual description of the certificate's public key algorithm. The property contains either the name of the algorithm (e.g., "RSA" or "RSA_DH") or an object identifier (OID) string representing the algorithm.
Data Type
String
CertPublicKeyLength Property (CertMgr Class)
This is the length of the certificate's public key (in bits).
Syntax
ANSI (Cross Platform) int GetCertPublicKeyLength(); Unicode (Windows) INT GetCertPublicKeyLength();
int ipworksiot_certmgr_getcertpublickeylength(void* lpObj);
int GetCertPublicKeyLength();
Default Value
0
Remarks
This is the length of the certificate's public key (in bits). Common values are 512, 1024, and 2048.
This property is read-only.
Data Type
Integer
CertSerialNumber Property (CertMgr Class)
This is the serial number of the certificate encoded as a string.
Syntax
ANSI (Cross Platform) char* GetCertSerialNumber(); Unicode (Windows) LPWSTR GetCertSerialNumber();
char* ipworksiot_certmgr_getcertserialnumber(void* lpObj);
QString GetCertSerialNumber();
Default Value
""
Remarks
This is the serial number of the certificate encoded as a string. The number is encoded as a series of hexadecimal digits, with each pair representing a byte of the serial number.
This property is read-only.
Data Type
String
CertSignatureAlgorithm Property (CertMgr Class)
The property contains the text description of the certificate's signature algorithm.
Syntax
ANSI (Cross Platform) char* GetCertSignatureAlgorithm(); Unicode (Windows) LPWSTR GetCertSignatureAlgorithm();
char* ipworksiot_certmgr_getcertsignaturealgorithm(void* lpObj);
QString GetCertSignatureAlgorithm();
Default Value
""
Remarks
The property contains the text description of the certificate's signature algorithm. The property contains either the name of the algorithm (e.g., "RSA" or "RSA_MD5RSA") or an object identifier (OID) string representing the algorithm.
This property is read-only.
Data Type
String
CertSubject Property (CertMgr Class)
This is the subject of the certificate used for client authentication.
Syntax
ANSI (Cross Platform) char* GetCertSubject();
int SetCertSubject(const char* lpszCertSubject); Unicode (Windows) LPWSTR GetCertSubject();
INT SetCertSubject(LPCWSTR lpszCertSubject);
char* ipworksiot_certmgr_getcertsubject(void* lpObj);
int ipworksiot_certmgr_setcertsubject(void* lpObj, const char* lpszCertSubject);
QString GetCertSubject();
int SetCertSubject(QString qsCertSubject);
Default Value
""
Remarks
This is the subject of the certificate used for client authentication.
This property must be set after all other certificate properties are set. When this property is set, a search is performed in the current certificate store to locate a certificate with a matching subject.
If a matching certificate is found, the property is set to the full subject of the matching certificate.
If an exact match is not found, the store is searched for subjects containing the value of the property.
If a match is still not found, the property is set to an empty string, and no certificate is selected.
The special value "*" picks a random certificate in the certificate store.
The certificate subject is a comma-separated list of distinguished name fields and values. For instance, "CN=www.server.com, OU=test, C=US, E=support@nsoftware.com". Common fields and their meanings are as follows:
Field | Meaning |
CN | Common Name. This is commonly a hostname like www.server.com. |
O | Organization |
OU | Organizational Unit |
L | Locality |
S | State |
C | Country |
E | Email Address |
If a field value contains a comma, it must be quoted.
Data Type
String
CertSubjectAltNames Property (CertMgr Class)
This property contains comma-separated lists of alternative subject names for the certificate.
Syntax
ANSI (Cross Platform) char* GetCertSubjectAltNames(); Unicode (Windows) LPWSTR GetCertSubjectAltNames();
char* ipworksiot_certmgr_getcertsubjectaltnames(void* lpObj);
QString GetCertSubjectAltNames();
Default Value
""
Remarks
This property contains comma-separated lists of alternative subject names for the certificate.
This property is read-only.
Data Type
String
CertThumbprintMD5 Property (CertMgr Class)
This property contains the MD5 hash of the certificate.
Syntax
ANSI (Cross Platform) char* GetCertThumbprintMD5(); Unicode (Windows) LPWSTR GetCertThumbprintMD5();
char* ipworksiot_certmgr_getcertthumbprintmd5(void* lpObj);
QString GetCertThumbprintMD5();
Default Value
""
Remarks
This property contains the MD5 hash of the certificate. It is primarily used for X.509 certificates. If the hash does not already exist, it is automatically computed.
This property is read-only.
Data Type
String
CertThumbprintSHA1 Property (CertMgr Class)
This property contains the SHA-1 hash of the certificate.
Syntax
ANSI (Cross Platform) char* GetCertThumbprintSHA1(); Unicode (Windows) LPWSTR GetCertThumbprintSHA1();
char* ipworksiot_certmgr_getcertthumbprintsha1(void* lpObj);
QString GetCertThumbprintSHA1();
Default Value
""
Remarks
This property contains the SHA-1 hash of the certificate. It is primarily used for X.509 certificates. If the hash does not already exist, it is automatically computed.
This property is read-only.
Data Type
String
CertThumbprintSHA256 Property (CertMgr Class)
This property contains the SHA-256 hash of the certificate.
Syntax
ANSI (Cross Platform) char* GetCertThumbprintSHA256(); Unicode (Windows) LPWSTR GetCertThumbprintSHA256();
char* ipworksiot_certmgr_getcertthumbprintsha256(void* lpObj);
QString GetCertThumbprintSHA256();
Default Value
""
Remarks
This property contains the SHA-256 hash of the certificate. It is primarily used for X.509 certificates. If the hash does not already exist, it is automatically computed.
This property is read-only.
Data Type
String
CertUsage Property (CertMgr Class)
This property contains the text description of UsageFlags .
Syntax
ANSI (Cross Platform) char* GetCertUsage();
int SetCertUsage(const char* lpszCertUsage); Unicode (Windows) LPWSTR GetCertUsage();
INT SetCertUsage(LPCWSTR lpszCertUsage);
char* ipworksiot_certmgr_getcertusage(void* lpObj);
int ipworksiot_certmgr_setcertusage(void* lpObj, const char* lpszCertUsage);
QString GetCertUsage();
int SetCertUsage(QString qsCertUsage);
Default Value
""
Remarks
This property contains the text description of CertUsageFlags.
This value will be of one or more of the following strings and will be separated by commas:
- Digital Signatures
- Key Authentication
- Key Encryption
- Data Encryption
- Key Agreement
- Certificate Signing
- Key Signing
If the provider is OpenSSL, the value is a comma-separated list of X.509 certificate extension names.
Data Type
String
CertUsageFlags Property (CertMgr Class)
This property contains the flags that show intended use for the certificate.
Syntax
ANSI (Cross Platform) int GetCertUsageFlags();
int SetCertUsageFlags(int iCertUsageFlags); Unicode (Windows) INT GetCertUsageFlags();
INT SetCertUsageFlags(INT iCertUsageFlags);
int ipworksiot_certmgr_getcertusageflags(void* lpObj);
int ipworksiot_certmgr_setcertusageflags(void* lpObj, int iCertUsageFlags);
int GetCertUsageFlags();
int SetCertUsageFlags(int iCertUsageFlags);
Default Value
0
Remarks
This property contains the flags that show intended use for the certificate. The value of CertUsageFlags is a combination of the following flags:
0x80 | Digital Signatures |
0x40 | Key Authentication (Non-Repudiation) |
0x20 | Key Encryption |
0x10 | Data Encryption |
0x08 | Key Agreement |
0x04 | Certificate Signing |
0x02 | Key Signing |
Please see the CertUsage property for a text representation of CertUsageFlags.
This functionality currently is not available when the provider is OpenSSL.
Data Type
Integer
CertVersion Property (CertMgr Class)
This property contains the certificate's version number.
Syntax
ANSI (Cross Platform) char* GetCertVersion(); Unicode (Windows) LPWSTR GetCertVersion();
char* ipworksiot_certmgr_getcertversion(void* lpObj);
QString GetCertVersion();
Default Value
""
Remarks
This property contains the certificate's version number. The possible values are the strings "V1", "V2", and "V3".
This property is read-only.
Data Type
String
CertExtensionCount Property (CertMgr Class)
The number of records in the CertExtension arrays.
Syntax
ANSI (Cross Platform) int GetCertExtensionCount();
int SetCertExtensionCount(int iCertExtensionCount); Unicode (Windows) INT GetCertExtensionCount();
INT SetCertExtensionCount(INT iCertExtensionCount);
int ipworksiot_certmgr_getcertextensioncount(void* lpObj);
int ipworksiot_certmgr_setcertextensioncount(void* lpObj, int iCertExtensionCount);
int GetCertExtensionCount();
int SetCertExtensionCount(int iCertExtensionCount);
Default Value
0
Remarks
This property controls the size of the following arrays:
The array indices start at 0 and end at CertExtensionCount - 1.This property is not available at design time.
Data Type
Integer
CertExtensionCritical Property (CertMgr Class)
This property specifies whether or not the extension is defined as critical.
Syntax
ANSI (Cross Platform) int GetCertExtensionCritical(int iCertExtensionIndex); Unicode (Windows) BOOL GetCertExtensionCritical(INT iCertExtensionIndex);
int ipworksiot_certmgr_getcertextensioncritical(void* lpObj, int certextensionindex);
bool GetCertExtensionCritical(int iCertExtensionIndex);
Default Value
FALSE
Remarks
This property specifies whether or not the extension is defined as critical.
The CertExtensionIndex parameter specifies the index of the item in the array. The size of the array is controlled by the CertExtensionCount property.
This property is read-only and not available at design time.
Data Type
Boolean
CertExtensionOID Property (CertMgr Class)
This property contains the ASN.
Syntax
ANSI (Cross Platform) char* GetCertExtensionOID(int iCertExtensionIndex); Unicode (Windows) LPWSTR GetCertExtensionOID(INT iCertExtensionIndex);
char* ipworksiot_certmgr_getcertextensionoid(void* lpObj, int certextensionindex);
QString GetCertExtensionOID(int iCertExtensionIndex);
Default Value
""
Remarks
This property contains the ASN.1 Object-Identifier (OID) that defines this certificate extension.
The CertExtensionIndex parameter specifies the index of the item in the array. The size of the array is controlled by the CertExtensionCount property.
This property is read-only and not available at design time.
Data Type
String
CertExtensionValue Property (CertMgr Class)
This property contains the raw value of the certificate extension.
Syntax
ANSI (Cross Platform) int GetCertExtensionValue(int iCertExtensionIndex, char* &lpCertExtensionValue, int &lenCertExtensionValue); Unicode (Windows) INT GetCertExtensionValue(INT iCertExtensionIndex, LPSTR &lpCertExtensionValue, INT &lenCertExtensionValue);
int ipworksiot_certmgr_getcertextensionvalue(void* lpObj, int certextensionindex, char** lpCertExtensionValue, int* lenCertExtensionValue);
QByteArray GetCertExtensionValue(int iCertExtensionIndex);
Default Value
""
Remarks
This property contains the raw value of the certificate extension. This value is encoded according to the extension's ASN.1 specification and should contain everything following the OID. The following example is provided for clarity.
The example will
- Add a sequence of basicConstraints indicating the holder of this certificate may not act as a CA.
- Add a sequence of cRLDistributionPoints showing where to get CRLs.
Certmgr mgr = new Certmgr();
mgr.Cert = new Certificate(CertStoreTypes.cstPFXFile, @"C:\signingcert.pfx", "password", "*");
mgr.CertExtensions.Clear();
mgr.Config("CertUsageFlags=0xA0"); //Key Encryption and Digital Signatures
mgr.Config("CertExtendedKeyUsage=1.3.6.1.5.5.7.3.1,1.3.6.1.5.5.7.3.2"); //Server and Client authentication (respectively)
mgr.Config("CertValidityTime=10000");
Netcode nc = new Netcode();
nc.Format = NetcodeFormats.fmtHex;
// Set basicConstraints to be an end-entity.
// Below is the hex-encoded value broken down.
// 30 // Tag = sequence
// 03 // Length
// 01 // Tag = boolean
// 01 // Length
// 00 // False (not a CA)
// Convert hex string to byte[]
nc.EncodedData = "3003010100";
nc.Decode();
string oid = "2.5.29.19"; // basicConstraints
byte[] value = nc.DecodedDataB;
bool critical = false;
CertExtension basicConstraints = new CertExtension(oid, value, critical);
mgr.CertExtensions.Add(basicConstraints);
// Add one point: http://www.nsoftware.com/dummy/MyCA.crl
// Below is the hex-encoded value broken down.
// 30 // Tag = sequence
// 2F // Length
// 30 // Tag = DistributionPoint
// 2D // Length
// A0 // Tag = DistributionPointName
// 2B // Length
// A0 // Tag = GeneralNames
// 29 // Length
// 86 // Tag = GeneralName
// 27 // Length
// 687474703A2F2F7777772E6E736F6674776172652E636F6D2F64756D6D792F4D7943412E63726C // URL
// Convert hex string to byte[]
nc.EncodedData = "302F302DA02BA0298627687474703A2F2F7777772E6E736F6674776172652E636F6D2F64756D6D792F4D7943412E63726C";
nc.Decode();
oid = "2.5.29.31"; // cRLDistributionPoints
value = nc.DecodedDataB;
critical = false;
CertExtension crlDistributionPoints = new CertExtension(oid, value, critical);
mgr.CertExtensions.Add(crlDistributionPoints);
mgr.IssueCertificate("CN=www.petsbymatilda.com", 123);
Console.WriteLine(mgr.Cert.Encoded);
The CertExtensionIndex parameter specifies the index of the item in the array. The size of the array is controlled by the CertExtensionCount property.
This property is read-only and not available at design time.
Data Type
Binary String
CertStore Property (CertMgr Class)
This is the certificate store to search for certificates.
Syntax
ANSI (Cross Platform) int GetCertStore(char* &lpCertStore, int &lenCertStore);
int SetCertStore(const char* lpCertStore, int lenCertStore); Unicode (Windows) INT GetCertStore(LPSTR &lpCertStore, INT &lenCertStore);
INT SetCertStore(LPCSTR lpCertStore, INT lenCertStore);
int ipworksiot_certmgr_getcertstore(void* lpObj, char** lpCertStore, int* lenCertStore);
int ipworksiot_certmgr_setcertstore(void* lpObj, const char* lpCertStore, int lenCertStore);
QByteArray GetCertStore();
int SetCertStore(QByteArray qbaCertStore);
Default Value
"MY"
Remarks
The CertStoreType property specifies the type of the certificate store specified by CertStore. If the store is password protected, specify the password in CertStorePassword.
Designations of certificate stores are platform dependent.
The following designations are the most common User and Machine certificate stores in Windows:
MY | A certificate store holding personal certificates with their associated private keys. |
CA | Certifying authority certificates. |
ROOT | Root certificates. |
When the certificate store type is PFXFile, this property must be set to the name of the file. When the type is PFXBlob, the property must be set to the binary contents of a PFX file (i.e., PKCS#12 certificate store).
Data Type
Binary String
CertStorePassword Property (CertMgr Class)
This is the password for the certificate store (if any).
Syntax
ANSI (Cross Platform) char* GetCertStorePassword();
int SetCertStorePassword(const char* lpszCertStorePassword); Unicode (Windows) LPWSTR GetCertStorePassword();
INT SetCertStorePassword(LPCWSTR lpszCertStorePassword);
char* ipworksiot_certmgr_getcertstorepassword(void* lpObj);
int ipworksiot_certmgr_setcertstorepassword(void* lpObj, const char* lpszCertStorePassword);
QString GetCertStorePassword();
int SetCertStorePassword(QString qsCertStorePassword);
Default Value
""
Remarks
The value of this property is used to open the certificate store if the certificate store requires a password.
Data Type
String
CertStoreType Property (CertMgr Class)
This is the type of certificate store for CertStore .
Syntax
ANSI (Cross Platform) int GetCertStoreType();
int SetCertStoreType(int iCertStoreType); Unicode (Windows) INT GetCertStoreType();
INT SetCertStoreType(INT iCertStoreType);
Possible Values
CST_USER(0),
CST_MACHINE(1),
CST_PFXFILE(2),
CST_PFXBLOB(3),
CST_JKSFILE(4),
CST_JKSBLOB(5),
CST_PEMKEY_FILE(6),
CST_PEMKEY_BLOB(7),
CST_PUBLIC_KEY_FILE(8),
CST_PUBLIC_KEY_BLOB(9),
CST_SSHPUBLIC_KEY_BLOB(10),
CST_P7BFILE(11),
CST_P7BBLOB(12),
CST_SSHPUBLIC_KEY_FILE(13),
CST_PPKFILE(14),
CST_PPKBLOB(15),
CST_XMLFILE(16),
CST_XMLBLOB(17),
CST_JWKFILE(18),
CST_JWKBLOB(19),
CST_SECURITY_KEY(20),
CST_BCFKSFILE(21),
CST_BCFKSBLOB(22),
CST_PKCS11(23),
CST_AUTO(99)
int ipworksiot_certmgr_getcertstoretype(void* lpObj);
int ipworksiot_certmgr_setcertstoretype(void* lpObj, int iCertStoreType);
int GetCertStoreType();
int SetCertStoreType(int iCertStoreType);
Default Value
0
Remarks
The class supports both public and private keys in a variety of formats. When the cstAuto value is used, the class will automatically determine the type. This property can take one of the following values:
0 (cstUser - default) | For Windows, this specifies that the certificate store is a certificate store owned by the current user.
Note: This store type is not available in Java. |
1 (cstMachine) | For Windows, this specifies that the certificate store is a machine store.
Note: This store type is not available in Java. |
2 (cstPFXFile) | The certificate store is the name of a PFX (PKCS#12) file containing certificates. |
3 (cstPFXBlob) | The certificate store is a string (binary or Base64-encoded) representing a certificate store in PFX (PKCS#12) format. |
4 (cstJKSFile) | The certificate store is the name of a Java Key Store (JKS) file containing certificates.
Note: This store type is only available in Java. |
5 (cstJKSBlob) | The certificate store is a string (binary or Base64-encoded) representing a certificate store in Java Key Store (JKS) format.
Note: this store type is only available in Java. |
6 (cstPEMKeyFile) | The certificate store is the name of a PEM-encoded file that contains a private key and an optional certificate. |
7 (cstPEMKeyBlob) | The certificate store is a string (binary or Base64-encoded) that contains a private key and an optional certificate. |
8 (cstPublicKeyFile) | The certificate store is the name of a file that contains a PEM- or DER-encoded public key certificate. |
9 (cstPublicKeyBlob) | The certificate store is a string (binary or Base64-encoded) that contains a PEM- or DER-encoded public key certificate. |
10 (cstSSHPublicKeyBlob) | The certificate store is a string (binary or Base64-encoded) that contains an SSH-style public key. |
11 (cstP7BFile) | The certificate store is the name of a PKCS#7 file containing certificates. |
12 (cstP7BBlob) | The certificate store is a string (binary) representing a certificate store in PKCS#7 format. |
13 (cstSSHPublicKeyFile) | The certificate store is the name of a file that contains an SSH-style public key. |
14 (cstPPKFile) | The certificate store is the name of a file that contains a PPK (PuTTY Private Key). |
15 (cstPPKBlob) | The certificate store is a string (binary) that contains a PPK (PuTTY Private Key). |
16 (cstXMLFile) | The certificate store is the name of a file that contains a certificate in XML format. |
17 (cstXMLBlob) | The certificate store is a string that contains a certificate in XML format. |
18 (cstJWKFile) | The certificate store is the name of a file that contains a JWK (JSON Web Key). |
19 (cstJWKBlob) | The certificate store is a string that contains a JWK (JSON Web Key). |
21 (cstBCFKSFile) | The certificate store is the name of a file that contains a BCFKS (Bouncy Castle FIPS Key Store).
Note: This store type is only available in Java and .NET. |
22 (cstBCFKSBlob) | The certificate store is a string (binary or Base64-encoded) representing a certificate store in BCFKS (Bouncy Castle FIPS Key Store) format.
Note: This store type is only available in Java and .NET. |
23 (cstPKCS11) | The certificate is present on a physical security key accessible via a PKCS#11 interface.
To use a security key, the necessary data must first be collected using the CertMgr class. The ListStoreCertificates method may be called after setting CertStoreType to cstPKCS11, CertStorePassword to the PIN, and CertStore to the full path of the PKCS#11 DLL. The certificate information returned in the CertList event's CertEncoded parameter may be saved for later use. When using a certificate, pass the previously saved security key information as the and set to the PIN. Code Example. SSH Authentication with Security Key:
|
99 (cstAuto) | The store type is automatically detected from the input data. This setting may be used with both public and private keys and can detect any of the supported formats automatically. |
Data Type
Integer
ExportedCert Property (CertMgr Class)
This is the exported certificate string.
Syntax
ANSI (Cross Platform) int GetExportedCert(char* &lpExportedCert, int &lenExportedCert); Unicode (Windows) INT GetExportedCert(LPSTR &lpExportedCert, INT &lenExportedCert);
int ipworksiot_certmgr_getexportedcert(void* lpObj, char** lpExportedCert, int* lenExportedCert);
QByteArray GetExportedCert();
Default Value
""
Remarks
This property holds the exported certificate if it was not exported to a file.
When calling ExportCertificate if the CertFile parameter is an empty string, the certificate will be exported as a string and available in this property. This allows certificate data to be exported without writing any data to disk.
When ExportFormat is set to PFX or P7B, the EncodeExportedCert setting controls whether the value is binary or Base64 encoded.
This property is read-only and not available at design time.
Data Type
Binary String
ExportFormat Property (CertMgr Class)
This is the format to which the certificate is exported.
Syntax
ANSI (Cross Platform) char* GetExportFormat();
int SetExportFormat(const char* lpszExportFormat); Unicode (Windows) LPWSTR GetExportFormat();
INT SetExportFormat(LPCWSTR lpszExportFormat);
char* ipworksiot_certmgr_getexportformat(void* lpObj);
int ipworksiot_certmgr_setexportformat(void* lpObj, const char* lpszExportFormat);
QString GetExportFormat();
int SetExportFormat(QString qsExportFormat);
Default Value
"PFX"
Remarks
ExportFormat is applicable when ExportCertificate is called and may be used to specify the output format. The applicability of each format depends on whether ExportPrivateKey is set. Some formats are applicable only when exporting to a private key and some values are applicable only when exporting to a public key.
ExportFormat | Applicability | Description |
"PFX" or "PKCS12" (default) | Private Keys | A PFX file (PKCS12). |
"PEM" | Public and Private Keys |
A PEM-formatted public certificate (X509/PKCS1/PKCS8), or PEM formatted private key (PKCS1/PKCS8). When ExportPrivateKey is False the exported certificate will be a PEM formatted X509 public certificate if the certificate being exported includes X509 data. If no X509 information is present, the public key will be exported in PKCS1 public key format for RSA/DSA keys and PKCS8 public key format for ECDSA/EdDSA keys. When ExportPrivateKey is True the exported certificate will be a PEM-formatted PKCS1 private key for RSA/DSA keys and a PEM-formatted PKCS8 private key for ECDSA/EdDSA keys. For example, when ExportPrivateKey is False: -----BEGIN CERTIFICATE----- MIIBkTCB+6ADAgECAgEBMA0GCSqGSIb3DQEBBQUAMA4xDDAKBgNVBAMTAzEwMDAgFw0wNzAx ... Pg49SpQ+HcUibIpum2O0hmnySH7BPGfXD8Lu -----END CERTIFICATE-----Example when ExportPrivateKey is True: -----BEGIN RSA PRIVATE KEY----- MIICWwIBAAKBgQD5/STHUd7YkN1JyoyYnUvCf+Fyx1+ZleBJxvwDcm3yaZ98bvry ... 91y8ydb3mQ9l1hZudo2sj8tHnvEgph0r7B8hMM6Qaw== -----END RSA PRIVATE KEY----- |
"PKCS1" | Public and Private Keys | A PEM-formatted PKCS1 key file.
For example, when ExportPrivateKey is False: -----BEGIN RSA PUBLIC KEY----- MIGJAoGBALAyxV5assz+9v7aHbj93NYN5uGB/1z7kb2Nx4hj02QyRYbcD4htkhK4Qcq2GCsG ... MxW4+pdeN4oEZ6rbMZt01bvMwNRX2GDEyQBhAgMBAAE= -----END RSA PUBLIC KEY-----Example when ExportPrivateKey is True: -----BEGIN RSA PRIVATE KEY----- MIICWwIBAAKBgQD5/STHUd7YkN1JyoyYnUvCf+Fyx1+ZleBJxvwDcm3yaZ98bvry ... 91y8ydb3mQ9l1hZudo2sj8tHnvEgph0r7B8hMM6Qaw== -----END RSA PRIVATE KEY----- |
"PKCS8" | Public and Private Keys | A PEM-formatted PKCS8 key file.
Example when ExportPrivateKey is False: -----BEGIN PUBLIC KEY----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCxdTNtpJQbw90cq6aJEx5vRIBrAiCAB9/F ... 8UdUliXeU8UGYjVcMhGy5oPsVeBXGcPAqF2mjXdBKNnzlSlctOLnYRBS5jwRuNfTQQIDAQAB -----END PUBLIC KEY-----Example when ExportPrivateKey is True: -----BEGIN PRIVATE KEY----- MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAPn9JMdR3tiQ3UnK ... HSvsHyEwzpBr -----END PRIVATE KEY----- |
"OpenSSH" | Public and Private Keys | An OpenSSH public or private key file.
For example, when ExportPrivateKey is False: ssh-rsa AAAAB3NzaC1y...Example when ExportPrivateKey is True: -----BEGIN OPENSSH PRIVATE KEY----- b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAlwAAAAdzc2gtcnNh ... AwQFBgcICQo= -----END OPENSSH PRIVATE KEY----- |
"PPK" | Private Keys | A PuTTY private key file.
For example, PuTTY-User-Key-File-2: ssh-rsa Encryption: none Comment: rsa-key-20180822 Public-Lines: 4 AAAAB3NzaC1yc2EAAAADAQABAAAAgQCmz5j5kWUKxfwiv6J0LQ4wN9ekpeORXVaP ... 8pSSWejQ5Q== Private-Lines: 8 AAAAgH87Sp/YcSw1dKoAZuWb0/2dKkKwMRIYEkS15caRpzAteay6WWX7l1sgBTU7 ... Oa0= Private-MAC: d53e24f44bde8d1d3844a142fbb1fa7c88ea3585 |
"SSH2PublicKey" | Public Keys | An SSH2 public key.
For example, ---- BEGIN SSH2 PUBLIC KEY ---- AAAAB3NzaC1yc2EAAAADAQABAAAAgQD5/STHUd7YkN1JyoyYnUvCf+Fyx1+ZleBJxvwDcm3y ... 6bVPTODELil1PVWJDlfdwoLZZKY2ACFHzxBqaOlYv1rbd2JIYAuqGca2ow== ---- END SSH2 PUBLIC KEY ---- |
"SSH2PrivateKey" | Private Keys | An SSH2 private key.
For example, ---- BEGIN SSH2 ENCRYPTED PRIVATE KEY ---- AAAAB3NzaC1yc2EAAAADAQABAAAAgQD5/STHUd7YkN1JyoyYnUvCf+Fyx1+ZleBJxvwDcm3y ... 6bVPTODELil1PVWJDlfdwoLZZKY2ACFHzxBqaOlYv1rbd2JIYAuqGca2ow== ---- END SSH2 ENCRYPTED PRIVATE KEY ---- |
"JWK" | Private and Public Keys | A JSON Web Key (JWK).
For example, when ExportPrivateKey is False: { "kty": "EC", "crv": "P-256", "x": "M_P_uqzP43FYW-kXWlpEDlX3nPZUr1QaMllAxUnao7w", "y": "zRFhp7iCXYIoTgerQ4LjGPTujodlimrwIMk-3enj_1Q" }For example, when ExportPrivateKey is True: { "kty": "EC", "crv": "P-256", "x": "M_P_uqzP43FYW-kXWlpEDlX3nPZUr1QaMllAxUnao7w", "y": "zRFhp7iCXYIoTgerQ4LjGPTujodlimrwIMk-3enj_1Q", "d": "eFBtl-uaB9Y4b-CIav5IYX4gGRFBvpBmrMOOQ7L-euI" } |
"XML" | Private and Public Keys | An XML file holding the key or X509 data.
For example, when ExportPrivateKey is False: <X509Data> <X509Certificate>MIIB...D8Lu</X509Certificate> </X509Data>For example, when ExportPrivateKey is True: <RSAKeyValue> <Modulus>+f0k...tqM=</Modulus> <Exponent>AQAB</Exponent> <P>/cOnF...tGw==</P> <Q>/DD5...dGQ==</Q> <DP>d75...N0w==</DP> <DQ>Cyv...rKQ==</DQ> <InverseQ>fsB...Qaw==</InverseQ> <D>J7p...YJE=</D> </RSAKeyValue> |
Data Type
String
ExportPrivateKey Property (CertMgr Class)
This controls whether to export the private key.
Syntax
ANSI (Cross Platform) int GetExportPrivateKey();
int SetExportPrivateKey(int bExportPrivateKey); Unicode (Windows) BOOL GetExportPrivateKey();
INT SetExportPrivateKey(BOOL bExportPrivateKey);
int ipworksiot_certmgr_getexportprivatekey(void* lpObj);
int ipworksiot_certmgr_setexportprivatekey(void* lpObj, int bExportPrivateKey);
bool GetExportPrivateKey();
int SetExportPrivateKey(bool bExportPrivateKey);
Default Value
TRUE
Remarks
This property controls whether the private key is exported when ExportCertificate is called.
If set to True (default), the private key is exported. If set to False, only the public key is exported.
Data Type
Boolean
Config Method (CertMgr Class)
Sets or retrieves a configuration setting.
Syntax
ANSI (Cross Platform) char* Config(const char* lpszConfigurationString); Unicode (Windows) LPWSTR Config(LPCWSTR lpszConfigurationString);
char* ipworksiot_certmgr_config(void* lpObj, const char* lpszConfigurationString);
QString Config(const QString& qsConfigurationString);
Remarks
Config is a generic method available in every class. It is used to set and retrieve configuration settings for the class.
These settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the class, access to these internal properties is provided through the Config method.
To set a configuration setting named PROPERTY, you must call Config("PROPERTY=VALUE"), where VALUE is the value of the setting expressed as a string. For boolean values, use the strings "True", "False", "0", "1", "Yes", or "No" (case does not matter).
To read (query) the value of a configuration setting, you must call Config("PROPERTY"). The value will be returned as a string.
Error Handling (C++)
This method returns a String value; after it returns, call the GetLastErrorCode() method to obtain its result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message.
CreateCertificate Method (CertMgr Class)
This method creates a new self-signed certificate in the current store.
Syntax
ANSI (Cross Platform) int CreateCertificate(const char* lpszCertSubject, int iSerialNumber); Unicode (Windows) INT CreateCertificate(LPCWSTR lpszCertSubject, INT iSerialNumber);
int ipworksiot_certmgr_createcertificate(void* lpObj, const char* lpszCertSubject, int iSerialNumber);
int CreateCertificate(const QString& qsCertSubject, int iSerialNumber);
Remarks
This method creates a new self-signed certificate in the current store, which contains the following:
CertSubject specifies the subject of the new certificate. A new keyset (public/private key pair) is generated and associated with the new certificate.
The certificate subject is a comma-separated list of distinguished name fields and values. For instance, "CN=www.server.com, OU=test, C=US, E=support@nsoftware.com". Common fields and their meanings are as follows:
Field | Meaning |
CN | Common Name. This is commonly a hostname like www.server.com. |
O | Organization |
OU | Organizational Unit |
L | Locality |
S | State |
C | Country |
E | Email Address |
If a field value contains a comma, it must be quoted.
SerialNumber specifies the certificate serial number. All certificates signed by the same issuer must have different (unique) serial numbers.
The time validity of the new certificate is determined by the CertValidityTime configuration setting, and the key size by the CertKeyLength configuration setting.
In the Unix edition of the toolkit, the certificate will be created in memory. Call ExportCertificate to export the newly created certificate to a PEM file.
Error Handling (C++)
This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)
CreateKey Method (CertMgr Class)
This method creates a new keyset associated with the provided name.
Syntax
ANSI (Cross Platform) int CreateKey(const char* lpszKeyName); Unicode (Windows) INT CreateKey(LPCWSTR lpszKeyName);
int ipworksiot_certmgr_createkey(void* lpObj, const char* lpszKeyName);
int CreateKey(const QString& qsKeyName);
Remarks
This method will create a new keyset (public/private key pair) within the Cryptographic Service Provider (CSP) used by the class. The CSP can be set using the CSP configuration setting.
NOTE: This functionality is only available in Windows.
Error Handling (C++)
This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)
DeleteCertificate Method (CertMgr Class)
This method deletes the currently selected certificate from the store.
Syntax
ANSI (Cross Platform) int DeleteCertificate(); Unicode (Windows) INT DeleteCertificate();
int ipworksiot_certmgr_deletecertificate(void* lpObj);
int DeleteCertificate();
Remarks
This method will delete the selected certificate from the store. If the certificate cannot be deleted, an error is returned.
This functionality is currently not available when the provider is OpenSSL.
Error Handling (C++)
This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)
DeleteKey Method (CertMgr Class)
This method deletes the keyset associated with the provided name.
Syntax
ANSI (Cross Platform) int DeleteKey(const char* lpszKeyName); Unicode (Windows) INT DeleteKey(LPCWSTR lpszKeyName);
int ipworksiot_certmgr_deletekey(void* lpObj, const char* lpszKeyName);
int DeleteKey(const QString& qsKeyName);
Remarks
This method will delete the keyset (public/private key pair) associated with KeyName from the Cryptographic Service Provider (CSP). The CSP can be set using the CSP configuration setting.
NOTE: This functionality is only available in Windows.
Error Handling (C++)
This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)
ExportCertificate Method (CertMgr Class)
This method exports the currently selected certificate.
Syntax
ANSI (Cross Platform) int ExportCertificate(const char* lpszCertFile, const char* lpszPassword); Unicode (Windows) INT ExportCertificate(LPCWSTR lpszCertFile, LPCWSTR lpszPassword);
int ipworksiot_certmgr_exportcertificate(void* lpObj, const char* lpszCertFile, const char* lpszPassword);
int ExportCertificate(const QString& qsCertFile, const QString& qsPassword);
Remarks
This method exports the certificate currently selected by CertSubject to the file specified by the CertFile parameter in the format specified by ExportFormat. This method may be used effectively to convert between a variety of formats.
The Password parameter specifies a password for the private key when ExportPrivateKey is set to True. Password is not applicable when ExportPrivateKey is set to False.
If CertFile is set to an empty string, the exported certificate will not be written to disk and instead will be held as a string by the ExportedCert property.
ExportFormat is applicable when ExportCertificate is called and may be used to specify the output format. The applicability of each format depends on whether ExportPrivateKey is set. Some formats are applicable only when exporting to a private key and some values are applicable only when exporting to a public key.
ExportFormat | Applicability | Description |
"PFX" or "PKCS12" (default) | Private Keys | A PFX file (PKCS12). |
"PEM" | Public and Private Keys |
A PEM-formatted public certificate (X509/PKCS1/PKCS8), or PEM formatted private key (PKCS1/PKCS8). When ExportPrivateKey is False the exported certificate will be a PEM formatted X509 public certificate if the certificate being exported includes X509 data. If no X509 information is present, the public key will be exported in PKCS1 public key format for RSA/DSA keys and PKCS8 public key format for ECDSA/EdDSA keys. When ExportPrivateKey is True the exported certificate will be a PEM-formatted PKCS1 private key for RSA/DSA keys and a PEM-formatted PKCS8 private key for ECDSA/EdDSA keys. For example, when ExportPrivateKey is False: -----BEGIN CERTIFICATE----- MIIBkTCB+6ADAgECAgEBMA0GCSqGSIb3DQEBBQUAMA4xDDAKBgNVBAMTAzEwMDAgFw0wNzAx ... Pg49SpQ+HcUibIpum2O0hmnySH7BPGfXD8Lu -----END CERTIFICATE-----Example when ExportPrivateKey is True: -----BEGIN RSA PRIVATE KEY----- MIICWwIBAAKBgQD5/STHUd7YkN1JyoyYnUvCf+Fyx1+ZleBJxvwDcm3yaZ98bvry ... 91y8ydb3mQ9l1hZudo2sj8tHnvEgph0r7B8hMM6Qaw== -----END RSA PRIVATE KEY----- |
"PKCS1" | Public and Private Keys | A PEM-formatted PKCS1 key file.
For example, when ExportPrivateKey is False: -----BEGIN RSA PUBLIC KEY----- MIGJAoGBALAyxV5assz+9v7aHbj93NYN5uGB/1z7kb2Nx4hj02QyRYbcD4htkhK4Qcq2GCsG ... MxW4+pdeN4oEZ6rbMZt01bvMwNRX2GDEyQBhAgMBAAE= -----END RSA PUBLIC KEY-----Example when ExportPrivateKey is True: -----BEGIN RSA PRIVATE KEY----- MIICWwIBAAKBgQD5/STHUd7YkN1JyoyYnUvCf+Fyx1+ZleBJxvwDcm3yaZ98bvry ... 91y8ydb3mQ9l1hZudo2sj8tHnvEgph0r7B8hMM6Qaw== -----END RSA PRIVATE KEY----- |
"PKCS8" | Public and Private Keys | A PEM-formatted PKCS8 key file.
Example when ExportPrivateKey is False: -----BEGIN PUBLIC KEY----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCxdTNtpJQbw90cq6aJEx5vRIBrAiCAB9/F ... 8UdUliXeU8UGYjVcMhGy5oPsVeBXGcPAqF2mjXdBKNnzlSlctOLnYRBS5jwRuNfTQQIDAQAB -----END PUBLIC KEY-----Example when ExportPrivateKey is True: -----BEGIN PRIVATE KEY----- MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAPn9JMdR3tiQ3UnK ... HSvsHyEwzpBr -----END PRIVATE KEY----- |
"OpenSSH" | Public and Private Keys | An OpenSSH public or private key file.
For example, when ExportPrivateKey is False: ssh-rsa AAAAB3NzaC1y...Example when ExportPrivateKey is True: -----BEGIN OPENSSH PRIVATE KEY----- b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAlwAAAAdzc2gtcnNh ... AwQFBgcICQo= -----END OPENSSH PRIVATE KEY----- |
"PPK" | Private Keys | A PuTTY private key file.
For example, PuTTY-User-Key-File-2: ssh-rsa Encryption: none Comment: rsa-key-20180822 Public-Lines: 4 AAAAB3NzaC1yc2EAAAADAQABAAAAgQCmz5j5kWUKxfwiv6J0LQ4wN9ekpeORXVaP ... 8pSSWejQ5Q== Private-Lines: 8 AAAAgH87Sp/YcSw1dKoAZuWb0/2dKkKwMRIYEkS15caRpzAteay6WWX7l1sgBTU7 ... Oa0= Private-MAC: d53e24f44bde8d1d3844a142fbb1fa7c88ea3585 |
"SSH2PublicKey" | Public Keys | An SSH2 public key.
For example, ---- BEGIN SSH2 PUBLIC KEY ---- AAAAB3NzaC1yc2EAAAADAQABAAAAgQD5/STHUd7YkN1JyoyYnUvCf+Fyx1+ZleBJxvwDcm3y ... 6bVPTODELil1PVWJDlfdwoLZZKY2ACFHzxBqaOlYv1rbd2JIYAuqGca2ow== ---- END SSH2 PUBLIC KEY ---- |
"SSH2PrivateKey" | Private Keys | An SSH2 private key.
For example, ---- BEGIN SSH2 ENCRYPTED PRIVATE KEY ---- AAAAB3NzaC1yc2EAAAADAQABAAAAgQD5/STHUd7YkN1JyoyYnUvCf+Fyx1+ZleBJxvwDcm3y ... 6bVPTODELil1PVWJDlfdwoLZZKY2ACFHzxBqaOlYv1rbd2JIYAuqGca2ow== ---- END SSH2 ENCRYPTED PRIVATE KEY ---- |
"JWK" | Private and Public Keys | A JSON Web Key (JWK).
For example, when ExportPrivateKey is False: { "kty": "EC", "crv": "P-256", "x": "M_P_uqzP43FYW-kXWlpEDlX3nPZUr1QaMllAxUnao7w", "y": "zRFhp7iCXYIoTgerQ4LjGPTujodlimrwIMk-3enj_1Q" }For example, when ExportPrivateKey is True: { "kty": "EC", "crv": "P-256", "x": "M_P_uqzP43FYW-kXWlpEDlX3nPZUr1QaMllAxUnao7w", "y": "zRFhp7iCXYIoTgerQ4LjGPTujodlimrwIMk-3enj_1Q", "d": "eFBtl-uaB9Y4b-CIav5IYX4gGRFBvpBmrMOOQ7L-euI" } |
"XML" | Private and Public Keys | An XML file holding the key or X509 data.
For example, when ExportPrivateKey is False: <X509Data> <X509Certificate>MIIB...D8Lu</X509Certificate> </X509Data>For example, when ExportPrivateKey is True: <RSAKeyValue> <Modulus>+f0k...tqM=</Modulus> <Exponent>AQAB</Exponent> <P>/cOnF...tGw==</P> <Q>/DD5...dGQ==</Q> <DP>d75...N0w==</DP> <DQ>Cyv...rKQ==</DQ> <InverseQ>fsB...Qaw==</InverseQ> <D>J7p...YJE=</D> </RSAKeyValue> |
ExportCertificate Example:
//Convert from PFX to PPK
certmgr.SetCertStoreType(CST_PFXFILE);
certmgr.SetCertStore("..\\test.pfx", strlen("..\\test.pfx"));
certmgr.SetCertStorePassword("password");
certmgr.SetCertSubject("*");
certmgr.SetExportPrivateKey(true);
certmgr.SetExportFormat("PPK");
int ret_code = certmgr.ExportCertificate("..\\test.ppk", "newpassword");
//Export public certificate from PFX
certmgr.SetCertStoreType(CST_PFXFILE);
certmgr.SetCertStore("..\\test.pfx", strlen("..\\test.pfx"));
certmgr.SetCertStorePassword("password");
certmgr.SetCertSubject("*");
certmgr.SetExportPrivateKey(false);
certmgr.SetExportFormat("PEM");
ret_code = certmgr.ExportCertificate("..\\exported.cer", "");
//Convert .cer file to SSH2 Public Key
certmgr.SetCertStoreType(CST_PUBLIC_KEY_FILE);
certmgr.SetCertStore("..\\exported.cer", strlen("..\\exported.cer"));
certmgr.SetCertSubject("*");
certmgr.SetExportPrivateKey(false);
certmgr.SetExportFormat("SSH2PublicKey");
ret_code = certmgr.ExportCertificate("C:\\ssh2.pub", "");
Error Handling (C++)
This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)
GenerateCSR Method (CertMgr Class)
This method generates a new Certificate Signing Request (CSR) to be sent to a signing authority.
Syntax
ANSI (Cross Platform) char* GenerateCSR(const char* lpszCertSubject, const char* lpszKeyName); Unicode (Windows) LPWSTR GenerateCSR(LPCWSTR lpszCertSubject, LPCWSTR lpszKeyName);
char* ipworksiot_certmgr_generatecsr(void* lpObj, const char* lpszCertSubject, const char* lpszKeyName);
QString GenerateCSR(const QString& qsCertSubject, const QString& qsKeyName);
Remarks
This method will generate a new CSR to be sent to the signing authority. CertSubject specifies the subject of the CSR. KeyName specifies the name of the keyset (public/private key pair) to be used. If the keyset does not already exist in the Cryptographic Service Provider (CSP), the class will automatically generate one. To set the CSP, use the CSP configuration setting.
Note: Remember the name of the keyset that is used when creating a CSR. The keyset must be re-associated with the certificate after the trust authority has signed the CSR.
The certificate subject is a comma-separated list of distinguished name fields and values. For instance, "CN=www.server.com, OU=test, C=US, E=support@nsoftware.com". Common fields and their meanings are as follows:
Field | Meaning |
CN | Common Name. This is commonly a hostname like www.server.com. |
O | Organization |
OU | Organizational Unit |
L | Locality |
S | State |
C | Country |
E | Email Address |
If a field value contains a comma, it must be quoted.
NOTE: This functionality is only available in Windows.
Error Handling (C++)
This method returns a String value; after it returns, call the GetLastErrorCode() method to obtain its result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message.
ImportCertificate Method (CertMgr Class)
This method imports a certificate from a file into the current certificate store.
Syntax
ANSI (Cross Platform) int ImportCertificate(const char* lpszCertFile, const char* lpszPassword, const char* lpszSubject); Unicode (Windows) INT ImportCertificate(LPCWSTR lpszCertFile, LPCWSTR lpszPassword, LPCWSTR lpszSubject);
int ipworksiot_certmgr_importcertificate(void* lpObj, const char* lpszCertFile, const char* lpszPassword, const char* lpszSubject);
int ImportCertificate(const QString& qsCertFile, const QString& qsPassword, const QString& qsSubject);
Remarks
This method will import a certificate from a file into the current certificate store.
On Windows platforms, certificates may be imported only to the Windows certificate store. To load a certificate without importing it to a Windows store, set Cert*.
Certificate files with or without a private key may be imported. If the file specified by CertFile contains a private key, the private key will be imported along with the public certificate. If the file specified by CertFile contains only a public certificate, only the public certificate will be imported.
The Password parameter specifies the certificate password (if any). When importing a public certificate, set Password to an empty string.
The format of the certificate file being imported must contain valid X509 data to be imported. Not all certificate file formats include X509 data, such as PPK or PKCS8 private keys. If the CertFile is of a format that cannot be imported, the class fails with an error.
Note: On Linux-based operating systems, this method loads the specified certificate without importing into any system location.
Subject is optional. If empty, the first certificate in the store is loaded instead of the matching certificate.
ImportCertificate Example
//Import a PFX
certmgr.ImportCertificate("..\\test.pfx", "password", "*");
//Import a public certificate (CER)
certmgr.ImportCertificate("..\\test.cer", "", "*");
Error Handling (C++)
This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)
ImportSignedCSR Method (CertMgr Class)
This method mports a signed Certificate Signing Request (CSR).
Syntax
ANSI (Cross Platform) int ImportSignedCSR(const char* lpSignedCSR, int lenSignedCSR, const char* lpszKeyName); Unicode (Windows) INT ImportSignedCSR(LPCSTR lpSignedCSR, INT lenSignedCSR, LPCWSTR lpszKeyName);
int ipworksiot_certmgr_importsignedcsr(void* lpObj, const char* lpSignedCSR, int lenSignedCSR, const char* lpszKeyName);
int ImportSignedCSR(QByteArray qbaSignedCSR, const QString& qsKeyName);
Remarks
This method will import a signed CSR. SignedCSR specifies a certificate that has been signed by a trusted authority. KeyName is the name of the keyset (public/private key pair) that was used to create the original CSR.
NOTE: This functionality is only available in Windows.
Error Handling (C++)
This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)
IssueCertificate Method (CertMgr Class)
This creates a new certificate in the current store and is signed by the selected certificate.
Syntax
ANSI (Cross Platform) int IssueCertificate(const char* lpszCertSubject, int iSerialNumber); Unicode (Windows) INT IssueCertificate(LPCWSTR lpszCertSubject, INT iSerialNumber);
int ipworksiot_certmgr_issuecertificate(void* lpObj, const char* lpszCertSubject, int iSerialNumber);
int IssueCertificate(const QString& qsCertSubject, int iSerialNumber);
Remarks
This method creates a new certificate in the current store and is signed by the selected certificate. CertSubject specifies the subject of the new certificate. A new keyset (public/private key pair) is generated and associated with the new certificate.
The certificate subject is a comma-separated list of distinguished name fields and values. For instance, "CN=www.server.com, OU=test, C=US, E=support@nsoftware.com". Common fields and their meanings are as follows:
Field | Meaning |
CN | Common Name. This is commonly a hostname like www.server.com. |
O | Organization |
OU | Organizational Unit |
L | Locality |
S | State |
C | Country |
E | Email Address |
If a field value contains a comma, it must be quoted.
SerialNumber specifies the certificate serial number. All certificates signed by the same issuer must have different (unique) serial numbers.
The current certificate selected by the class will be used as the issuing certificate.
If no certificate has been selected in the current CertStore before calling this method, or if the selected certificate does not have an associated private key, the method fails with an error.
The time validity of the new certificate is determined by the CertValidityTime configuration setting, and the key size by the CertKeyLength configuration setting.
NOTE: This functionality is only available in Windows.
Error Handling (C++)
This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)
ListCertificateStores Method (CertMgr Class)
This lists the certificate stores.
Syntax
ANSI (Cross Platform) char* ListCertificateStores(); Unicode (Windows) LPWSTR ListCertificateStores();
char* ipworksiot_certmgr_listcertificatestores(void* lpObj);
QString ListCertificateStores();
Remarks
This method lists the system certificate stores for the current user account. The results are provided through the StoreList event.
The same information is also returned upon method completion as a set of lines and is given one per certificate store name.
NOTE: This functionality is only available in Windows.
Error Handling (C++)
This method returns a String value; after it returns, call the GetLastErrorCode() method to obtain its result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message.
ListKeys Method (CertMgr Class)
This lists the keysets in a Cryptographic Service Provider (CSP).
Syntax
ANSI (Cross Platform) char* ListKeys(); Unicode (Windows) LPWSTR ListKeys();
char* ipworksiot_certmgr_listkeys(void* lpObj);
QString ListKeys();
Remarks
This method lists the keys (public/private key pairs) in a CSP. The results are provided through the KeyList event.
The same information is also returned upon method completion as a set of lines and is given one per key, with each line containing the following information separated by Tab characters: KeyContainer, KeyType, AlgId, and KeyLen.
NOTE: This functionality is only available in Windows.
Error Handling (C++)
This method returns a String value; after it returns, call the GetLastErrorCode() method to obtain its result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message.
ListMachineStores Method (CertMgr Class)
This lists the machine certificate stores.
Syntax
ANSI (Cross Platform) char* ListMachineStores(); Unicode (Windows) LPWSTR ListMachineStores();
char* ipworksiot_certmgr_listmachinestores(void* lpObj);
QString ListMachineStores();
Remarks
This method behaves the same as the ListCertificateStores method, but it lists the certificate stores in the machine account (under HKEY_LOCAL_MACHINE in the registry).
NOTE: This functionality is only available in Windows.
Error Handling (C++)
This method returns a String value; after it returns, call the GetLastErrorCode() method to obtain its result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message.
ListStoreCertificates Method (CertMgr Class)
This lists the certificates in a store.
Syntax
ANSI (Cross Platform) char* ListStoreCertificates(); Unicode (Windows) LPWSTR ListStoreCertificates();
char* ipworksiot_certmgr_liststorecertificates(void* lpObj);
QString ListStoreCertificates();
Remarks
This method lists the certificates in a store. The results are provided through the CertList event.
The same information is also returned upon method completion as a set of lines and is given one per certificate, with each line containing the following information separated by Tab characters: CertSubject, CertIssuer, CertSerialNumber, and HasPrivateKey (as "1" or "0").
In the Unix edition of the toolkit, this is available only when a PFX file is loaded.
Error Handling (C++)
This method returns a String value; after it returns, call the GetLastErrorCode() method to obtain its result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message.
ReadCertificate Method (CertMgr Class)
This loads a certificate from a file.
Syntax
ANSI (Cross Platform) int ReadCertificate(const char* lpszFileName); Unicode (Windows) INT ReadCertificate(LPCWSTR lpszFileName);
int ipworksiot_certmgr_readcertificate(void* lpObj, const char* lpszFileName);
int ReadCertificate(const QString& qsFileName);
Remarks
Note: This method is present for backward compatibility. It is recommended to specify the Cert* properties to load a certificate.
This method will load a certificate from a file. The file contents can be encoded in Base64 PEM or ASN DER format.
Error Handling (C++)
This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)
ReadCSR Method (CertMgr Class)
This reads a Certificate Signing Request (CSR).
Syntax
ANSI (Cross Platform) char* ReadCSR(const char* lpszCSR); Unicode (Windows) LPWSTR ReadCSR(LPCWSTR lpszCSR);
char* ipworksiot_certmgr_readcsr(void* lpObj, const char* lpszCSR);
QString ReadCSR(const QString& qsCSR);
Remarks
This method reads a CSR and returns a string holding information about the CSR. The Cert property is also populated with relevant information about the CSR, including the following:
The method accepts the CSR parameter as either a Base64-encoded string PEM or a path to a file.The return value will be in the following format:
Certificate Request: Data: Version: 0 (0x0) Subject: C=AU, S=Some-State, O=Internet Widgits Pty Ltd Subject Public Key Info: Public Key Algorithm: X957_DSA (1.2.840.10040.4.1) Public-Key: (0 bit) pub: 02:82:01:00:66:70:68:60:08:63:bc:ff:26:62:77:74: f6:b8:a8:11:f4:2c:5d:a1:79:b9:8e:ea:30:2e:6b:5a: 1b:35:39:24:91:1b:c1:ba:49:a0:c5:af:47:6e:73:0a: f3:f6:6b:99:94:21:32:e5:24:b3:a8:a4:85:93:84:26: e8:5c:4a:5d:2e:5e:82:df:ab:cc:e5:8d:51:ac:45:c2: 09:e5:21:f1:ce:c9:a0:3d:1d:7a:ab:fa:dd:d6:56:a8: b2:61:26:8e:27:83:36:8a:0c:9b:cb:61:1a:b5:63:95: ef:a5:bd:f2:8e:a7:fc:ca:d2:81:87:a5:6a:88:03:2e: ca:fb:24:fa:d0:df:8a:2e:a9:e0:31:fc:57:e1:02:ca: ee:99:01:d2:a5:33:34:47:92:b3:8b:31:f5:f1:1d:bf: eb:07:70:71:6f:d1:c0:4c:0a:9d:99:af:ae:7e:bc:85: e4:d2:22:1c:38:4b:60:e8:31:4d:f7:10:06:10:03:55: f5:af:ba:a9:53:a5:9b:ae:d1:f8:38:34:80:e4:1c:9e: 06:8d:cc:39:3e:b2:e9:32:82:85:d2:d0:ed:b2:8e:d6: 6f:96:87:08:62:cc:9e:d3:75:76:b5:85:31:c6:a4:94: 59:15:ec:de:70:5a:34:2c:ff:27:ad:fc:14:01:e6:39: 8a:c9:91:3e: P: 00:dc:a6:15:cc:1a:e1:44:16:dc:a8:68:a4:18:9a:ab: bf:5d:bf:b7:d1:5e:38:5f:b6:0e:21:ef:df:83:6a:5c: 31:f0:c9:07:3c:13:2c:9c:32:d0:89:76:2b:80:ad:3f: 6b:5d:5a:1d:69:31:f5:80:d5:65:ba:b5:28:a3:38:ba: 93:25:c4:fc:93:99:a2:00:5d:5e:c6:1b:f2:63:f0:24: 72:52:b4:49:97:19:93:fe:47:bf:9e:2e:54:d1:8a:b9: 09:8d:54:e8:de:31:e8:0d:21:b0:81:b2:f5:bd:38:3c: 15:02:d6:c1:aa:ab:17:8f:a8:f8:1f:1b:34:09:85:75: 3d:6e:28:2d:72:af:47:fd:ae:c4:f3:78:53:d7:07:a7: c4:72:35:2d:6b:9e:42:08:1d:46:c9:38:d2:53:27:63: a2:1d:be:11:9f:dd:9d:5b:e4:ad:fa:71:30:61:84:60: a0:bf:bd:3a:51:b4:b5:1e:48:26:36:66:9e:52:f9:70: 35:e3:38:53:2e:90:ed:9f:0f:9d:67:b9:57:dd:53:e6: ca:92:58:40:6d:15:e4:ae:2e:16:74:33:ed:48:90:15: 30:b7:fd:47:58:91:d5:c5:e2:3b:1f:1d:3b:a7:59:40: 2e:22:1a:9a:89:1b:31:a2:6f:cf:4c:a1:3b:93:ed:8a: 11: Q: 00:e3:ae:12:04:80:be:0f:d4:78:ef:02:27:26:b3:64: 6d:2b:e0:c9:da:15:00:a9:9c:45:6d:e6:44:ef:dd:75: 71: G: 18:fb:52:54:fe:bc:54:9e:17:a9:51:a1:e0:b9:6a:ab: 48:0e:06:60:f3:cd:fd:3c:14:9a:a0:35:d1:33:d4:d8: b4:ee:ce:0b:5c:c7:60:24:e8:39:17:d8:75:13:90:44: f5:f6:ef:50:cd:b4:af:66:90:f7:00:13:66:2f:ea:e2: 29:39:cd:a4:16:20:df:00:fd:53:6d:02:8b:4f:09:a5: 7f:72:7c:28:c8:70:2a:85:49:a1:65:36:66:91:52:e7: 14:b1:b8:b9:79:39:a6:d5:f8:b9:cd:ce:af:2d:88:66: b5:d9:bb:9e:60:c8:9e:82:b4:3f:ff:23:37:4b:20:e4: 88:b0:d4:6e:b7:b5:8c:e6:98:cb:88:c2:6e:10:46:af: 44:0f:53:22:c2:fb:80:d3:30:05:c0:a6:4b:f8:e0:08: 3e:69:b6:17:b1:7d:2f:8f:07:66:9c:e5:94:3f:fc:ea: f9:6c:9d:49:7c:91:f3:5a:92:b4:a7:b9:dc:42:7d:1a: b0:99:ad:6d:b8:d9:03:6e:40:13:1c:3e:e2:80:f5:a1: da:75:49:29:be:36:ad:78:74:46:0d:00:e9:6d:bf:8c: 65:50:4c:ad:ba:a7:1c:ac:5a:13:9e:d6:6a:3a:9f:cb: 1f:7d:5d:e2:3e:79:22:c2:56:c8:70:74:53:9a:4e:6c: Attributes: Signature Algorithm: 2.16.840.1.101.3.4.3.2 (2.16.840.1.101.3.4.3.2) 00:30:44:02:20:42:00:86:14:2d:70:71:1b:77:b4:f0: ae:32:76:7b:1d:71:98:a2:70:69:4c:a9:e6:c1:9b:ad: df:af:a3:30:10:02:20:12:8f:ed:0b:1e:d5:f6:84:24: a9:fe:bc:45:75:eb:02:62:13:07:2c:ae:3f:ce:f3:da: 95:25:47:97:bf:a6:9e:
Error Handling (C++)
This method returns a String value; after it returns, call the GetLastErrorCode() method to obtain its result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message.
Reset Method (CertMgr Class)
This resets all certificate properties to their default values.
Syntax
ANSI (Cross Platform) int Reset(); Unicode (Windows) INT Reset();
int ipworksiot_certmgr_reset(void* lpObj);
int Reset();
Remarks
This method will reset all certificate properties to their default values. If a certificate and a private key are selected or a certificate store is opened, both are released upon calling this method.
Error Handling (C++)
This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)
SaveCertificate Method (CertMgr Class)
This method saves the currently selected public certificate to a file.
Syntax
ANSI (Cross Platform) int SaveCertificate(const char* lpszFileName); Unicode (Windows) INT SaveCertificate(LPCWSTR lpszFileName);
int ipworksiot_certmgr_savecertificate(void* lpObj, const char* lpszFileName);
int SaveCertificate(const QString& qsFileName);
Remarks
Note: This method is present for backward compatibility. It is recommended to use ExportCertificate to export both public and private certificates and keys.
This method saves the public certificate of the currently selected certificate in Base64 PEM format to the location specified by the FileName parameter.
If the destination file exists, it is overwritten.
Error Handling (C++)
This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)
ShowCertificateChain Method (CertMgr Class)
This shows the certificate chain.
Syntax
ANSI (Cross Platform) char* ShowCertificateChain(); Unicode (Windows) LPWSTR ShowCertificateChain();
char* ipworksiot_certmgr_showcertificatechain(void* lpObj);
QString ShowCertificateChain();
Remarks
This method shows the certificate chain for the certificate. The results are provided through the CertChain event.
The same information is also returned upon method completion as a set of lines and is given one per key, with each line containing the following information separated by Tab characters: CertSubject, CertIssuer, CertSerialNumber, TrustStatus, and TrustInfo.
NOTE: This functionality is only available in Windows.
Error Handling (C++)
This method returns a String value; after it returns, call the GetLastErrorCode() method to obtain its result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message.
SignCSR Method (CertMgr Class)
This creates a signed certificate from a Certificate Signing Request (CSR).
Syntax
ANSI (Cross Platform) char* SignCSR(const char* lpCSR, int lenCSR, int iSerialNumber); Unicode (Windows) LPWSTR SignCSR(LPCSTR lpCSR, INT lenCSR, INT iSerialNumber);
char* ipworksiot_certmgr_signcsr(void* lpObj, const char* lpCSR, int lenCSR, int iSerialNumber);
QString SignCSR(QByteArray qbaCSR, int iSerialNumber);
Remarks
This method will create a signed certificate from a CSR. CSR specifies the CSR to be signed.
SerialNumber specifies the certificate serial number. All certificates signed by the same issuer must have different (unique) serial numbers.
The time validity of the new certificate is determined by the CertValidityTime configuration setting, and the key size is determined by the CertKeyLength configuration setting.
NOTE: This functionality is only available in Windows.
Error Handling (C++)
This method returns a String value; after it returns, call the GetLastErrorCode() method to obtain its result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message.
CertChain Event (CertMgr Class)
This event shows the certificate chain for the certificate (see the ShowCertificateChain method).
Syntax
ANSI (Cross Platform) virtual int FireCertChain(CertMgrCertChainEventParams *e);
typedef struct {
const char *CertEncoded; int lenCertEncoded;
const char *CertSubject;
const char *CertIssuer;
const char *CertSerialNumber;
int TrustStatus;
int TrustInfo; int reserved; } CertMgrCertChainEventParams;
Unicode (Windows) virtual INT FireCertChain(CertMgrCertChainEventParams *e);
typedef struct {
LPCSTR CertEncoded; INT lenCertEncoded;
LPCWSTR CertSubject;
LPCWSTR CertIssuer;
LPCWSTR CertSerialNumber;
INT TrustStatus;
INT TrustInfo; INT reserved; } CertMgrCertChainEventParams;
#define EID_CERTMGR_CERTCHAIN 1 virtual INT IPWORKSIOT_CALL FireCertChain(LPSTR &lpCertEncoded, INT &lenCertEncoded, LPSTR &lpszCertSubject, LPSTR &lpszCertIssuer, LPSTR &lpszCertSerialNumber, INT &iTrustStatus, INT &iTrustInfo);
class CertMgrCertChainEventParams { public: const QByteArray &CertEncoded(); const QString &CertSubject(); const QString &CertIssuer(); const QString &CertSerialNumber(); int TrustStatus(); int TrustInfo(); int EventRetVal(); void SetEventRetVal(int iRetVal); };
// To handle, connect one or more slots to this signal. void CertChain(CertMgrCertChainEventParams *e);
// Or, subclass CertMgr and override this emitter function. virtual int FireCertChain(CertMgrCertChainEventParams *e) {...}
Remarks
This event is fired for every certificate in the certificate chain of the certificate assigned to the class.
The TrustStatus parameter contains information about the trust status of the entire certificate chain. A value of 0 signifies that the security subsystem has verified the certificate. Other values are combinations of one or more of the following flags:
0x00000001 | This certificate or one of the certificates in the certificate chain is not time valid. |
0x00000002 | Certificates in the chain are not properly time nested. |
0x00000004 | Trust for this certificate or one of the certificates in the certificate chain has been revoked. |
0x00000008 | This certificate or one of the certificates in the certificate chain does not have a valid signature. |
0x00000010 | The certificate or the certificate chain is not valid for its proposed usage. |
0x00000020 | The certificate or certificate chain is based on an untrusted root. |
0x00000040 | The revocation status of the certificate or one of the certificates in the certificate chain is unknown. |
0x00000080 | One of the certificates in the chain was issued by a certification authority that the original certificate had certified. |
0x00010000 | The certificate chain is not complete. |
0x00020000 | A certificate trust list (CTL) used to create this chain was not time valid. |
0x00040000 | A CTL used to create this chain did not have a valid signature. |
0x00080000 | A CTL used to create this chain is not valid for this usage. |
The TrustInfo parameter contains additional information about the status of the entire certificate chain. It is a combination of one or more of the following flags:
0x00000001 | An exact match issuer certificate has been found for this certificate. |
0x00000002 | A key match issuer certificate has been found for this certificate. |
0x00000004 | A name match issuer certificate has been found for this certificate. |
0x00000008 | This certificate is self-signed. |
0x00010000 | The certificate chain created is a complex chain. |
The CertSubject and CertIssuer parameters contain the distinguished names of the certificate owner and issuer, respectively.
CertList Event (CertMgr Class)
This event lists the certificates in a store (see the ListStoreCertificates method).
Syntax
ANSI (Cross Platform) virtual int FireCertList(CertMgrCertListEventParams *e);
typedef struct {
const char *CertEncoded; int lenCertEncoded;
const char *CertSubject;
const char *CertIssuer;
const char *CertSerialNumber;
int HasPrivateKey; int reserved; } CertMgrCertListEventParams;
Unicode (Windows) virtual INT FireCertList(CertMgrCertListEventParams *e);
typedef struct {
LPCSTR CertEncoded; INT lenCertEncoded;
LPCWSTR CertSubject;
LPCWSTR CertIssuer;
LPCWSTR CertSerialNumber;
BOOL HasPrivateKey; INT reserved; } CertMgrCertListEventParams;
#define EID_CERTMGR_CERTLIST 2 virtual INT IPWORKSIOT_CALL FireCertList(LPSTR &lpCertEncoded, INT &lenCertEncoded, LPSTR &lpszCertSubject, LPSTR &lpszCertIssuer, LPSTR &lpszCertSerialNumber, BOOL &bHasPrivateKey);
class CertMgrCertListEventParams { public: const QByteArray &CertEncoded(); const QString &CertSubject(); const QString &CertIssuer(); const QString &CertSerialNumber(); bool HasPrivateKey(); int EventRetVal(); void SetEventRetVal(int iRetVal); };
// To handle, connect one or more slots to this signal. void CertList(CertMgrCertListEventParams *e);
// Or, subclass CertMgr and override this emitter function. virtual int FireCertList(CertMgrCertListEventParams *e) {...}
Remarks
The CertSubject and CertIssuer parameters contain distinguished names of the certificate owner and issuer, respectively. The HasPrivateKey flag shows whether the private key for the certificate is available in the system.
The StoreList event and the ListCertificateStores and ListMachineStores methods are used to list the certificate stores in the system.
Error Event (CertMgr Class)
Information about errors during data delivery.
Syntax
ANSI (Cross Platform) virtual int FireError(CertMgrErrorEventParams *e);
typedef struct {
int ErrorCode;
const char *Description; int reserved; } CertMgrErrorEventParams;
Unicode (Windows) virtual INT FireError(CertMgrErrorEventParams *e);
typedef struct {
INT ErrorCode;
LPCWSTR Description; INT reserved; } CertMgrErrorEventParams;
#define EID_CERTMGR_ERROR 3 virtual INT IPWORKSIOT_CALL FireError(INT &iErrorCode, LPSTR &lpszDescription);
class CertMgrErrorEventParams { public: int ErrorCode(); const QString &Description(); int EventRetVal(); void SetEventRetVal(int iRetVal); };
// To handle, connect one or more slots to this signal. void Error(CertMgrErrorEventParams *e);
// Or, subclass CertMgr and override this emitter function. virtual int FireError(CertMgrErrorEventParams *e) {...}
Remarks
The Error event is fired in case of exceptional conditions during message processing. Normally the class fails with an error.
The ErrorCode parameter contains an error code, and the Description parameter contains a textual description of the error. For a list of valid error codes and their descriptions, please refer to the Error Codes section.
KeyList Event (CertMgr Class)
This lists the keysets in a Cryptographic Service Provider (CSP); see the ListKeys method.
Syntax
ANSI (Cross Platform) virtual int FireKeyList(CertMgrKeyListEventParams *e);
typedef struct {
const char *KeyContainer;
int KeyType;
const char *AlgId;
int KeyLen; int reserved; } CertMgrKeyListEventParams;
Unicode (Windows) virtual INT FireKeyList(CertMgrKeyListEventParams *e);
typedef struct {
LPCWSTR KeyContainer;
INT KeyType;
LPCWSTR AlgId;
INT KeyLen; INT reserved; } CertMgrKeyListEventParams;
#define EID_CERTMGR_KEYLIST 4 virtual INT IPWORKSIOT_CALL FireKeyList(LPSTR &lpszKeyContainer, INT &iKeyType, LPSTR &lpszAlgId, INT &iKeyLen);
class CertMgrKeyListEventParams { public: const QString &KeyContainer(); int KeyType(); const QString &AlgId(); int KeyLen(); int EventRetVal(); void SetEventRetVal(int iRetVal); };
// To handle, connect one or more slots to this signal. void KeyList(CertMgrKeyListEventParams *e);
// Or, subclass CertMgr and override this emitter function. virtual int FireKeyList(CertMgrKeyListEventParams *e) {...}
Remarks
The KeyContainer parameter is the name used to identify the keyset (public/private key pair) when it was first created.
KeyType shows the key type: 1 for key exchange (encryption) keys, and 2 for digital signature keys.
KeyLen shows the length of the public key (in bits).
Log Event (CertMgr Class)
This event fires once for each log message.
Syntax
ANSI (Cross Platform) virtual int FireLog(CertMgrLogEventParams *e);
typedef struct {
int LogLevel;
const char *Message;
const char *LogType; int reserved; } CertMgrLogEventParams;
Unicode (Windows) virtual INT FireLog(CertMgrLogEventParams *e);
typedef struct {
INT LogLevel;
LPCWSTR Message;
LPCWSTR LogType; INT reserved; } CertMgrLogEventParams;
#define EID_CERTMGR_LOG 5 virtual INT IPWORKSIOT_CALL FireLog(INT &iLogLevel, LPSTR &lpszMessage, LPSTR &lpszLogType);
class CertMgrLogEventParams { public: int LogLevel(); const QString &Message(); const QString &LogType(); int EventRetVal(); void SetEventRetVal(int iRetVal); };
// To handle, connect one or more slots to this signal. void Log(CertMgrLogEventParams *e);
// Or, subclass CertMgr and override this emitter function. virtual int FireLog(CertMgrLogEventParams *e) {...}
Remarks
This event fires once for each log message generated by the class. The verbosity is controlled by the LogLevel setting.
LogLevel indicates the level of message. Possible values are as follows:
0 (None) | No events are logged. |
1 (Info - default) | Informational events are logged. |
2 (Verbose) | Detailed data are logged. |
3 (Debug) | Debug data are logged. |
Message is the log entry.
LogType identifies the type of log entry.
StoreList Event (CertMgr Class)
This lists the system certificate stores (see the ListCertificateStores and ListMachineStores methods).
Syntax
ANSI (Cross Platform) virtual int FireStoreList(CertMgrStoreListEventParams *e);
typedef struct {
const char *CertStore; int reserved; } CertMgrStoreListEventParams;
Unicode (Windows) virtual INT FireStoreList(CertMgrStoreListEventParams *e);
typedef struct {
LPCWSTR CertStore; INT reserved; } CertMgrStoreListEventParams;
#define EID_CERTMGR_STORELIST 6 virtual INT IPWORKSIOT_CALL FireStoreList(LPSTR &lpszCertStore);
class CertMgrStoreListEventParams { public: const QString &CertStore(); int EventRetVal(); void SetEventRetVal(int iRetVal); };
// To handle, connect one or more slots to this signal. void StoreList(CertMgrStoreListEventParams *e);
// Or, subclass CertMgr and override this emitter function. virtual int FireStoreList(CertMgrStoreListEventParams *e) {...}
Remarks
The CertStore parameter contains the name of the certificate store being listed.
The CertList event and the ListStoreCertificates method are used to list the certificates in the store.
Config Settings (CertMgr Class)
The class accepts one or more of the following configuration settings. Configuration settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the class, access to these internal properties is provided through the Config method.CertMgr Config Settings
- OpenSSHKey (ExportPrivateKey must be False)
- SSH2PublicKey
- PPK
The array indices start at 0 and end at CertExtensionCount-1.
Valid array indices are from 0 to CertCustomExtensionCount - 1.
Valid array indices are from 0 to CertCustomExtensionCount - 1.
Valid array indices are from 0 to CertCustomExtensionCount - 1.
1.3.6.1.5.5.7.3.1 | Server Authentication |
1.3.6.1.5.5.7.3.2 | Client Authentication |
1.3.6.1.5.5.7.3.3 | Code Signing |
1.3.6.1.5.5.7.3.4 | Secure Email |
1.3.6.1.5.5.7.3.8 | Time Stamping |
1.3.6.1.5.5.7.3.9 | OCSP Signing |
For instance, the following value specified the extended key usage for Server Authentication, Client Authentication, and Code Signing: 1.3.6.1.5.5.7.3.1, 1.3.6.1.5.5.7.3.2, and 1.3.6.1.5.5.7.3.3
- RSA (default)
- DSA
- ECDSA_P256
- ECDSA_P384
- ECDSA_P521
- ECDSA_Secp256k1
- ECDSA_Secp224k1
- ECDSA_Secp192k1
- ECDSA_Secp160k1
- ECDSA_BRAINPOOLP160R1
- ECDSA_BRAINPOOLP192R1
- ECDSA_BRAINPOOLP224R1
- ECDSA_BRAINPOOLP256R1
- ECDSA_BRAINPOOLP320R1
- ECDSA_BRAINPOOLP384R1
- ECDSA_BRAINPOOLP512R1
- ECDSA_BRAINPOOLP160T1
- ECDSA_BRAINPOOLP192T1
- ECDSA_BRAINPOOLP224T1
- ECDSA_BRAINPOOLP256T1
- ECDSA_BRAINPOOLP320T1
- ECDSA_BRAINPOOLP384T1
- ECDSA_BRAINPOOLP512T1
- Ed25519
- Ed448
- MD2
- MD5
- SHA1
- SHA256 (default)
- SHA384
- SHA512
string altNames = "email:copy,dns:domain.com,dns.1:other.domain.com,uri:http://www.domain.com,ip:192.168.1.102"
This configuration setting is not supported in the C# and Java editions, which already support loading by thumbprint via the Certificate type constructors. This setting is only supported on Windows operating systems.
CertMgr cert;
cert.Config("CertThumbprint=967adafd7add8f72ee4894ede866d6745970f82f");
cert.SetCertStore("MY", 2);
cert.SetCertStoreType(CST_USER);
cert.SetCertStorePassword("");
cert.SetCertSubject("TestCert");
0x80 | Digital Signatures |
0x40 | Key Authentication |
0x20 | Key Encryption |
0x10 | Data Encryption |
0x08 | Key Agreement |
0x04 | Certificate Signing |
0x02 | Key Signing |
For example if the SAN's in a CSR should be ignored the below code would work:
CertMgr1->Config("CSRIgnoredExtensions=2.5.29.17");
The default value is False.
1 | CERT_STORE_ADD_NEW - Imports a certificate only if no existing certificate is present. |
2 | CERT_STORE_ADD_USE_EXISTING - If an existing certificate is found, it is not replaced. |
3 (default) | CERT_STORE_ADD_REPLACE_EXISTING - If an existing certificate is found it is replaced. |
4 | CERT_STORE_ADD_ALWAYS - No checks are performed and a new certificate is always added to the store. This can result in duplicates. |
5 | CERT_STORE_ADD_REPLACE_EXISTING_INHERIT_PROPERTIES - If an existing certificate is found it is replaced, and the new certificate inherits properties from the certificate it replaces. |
6 | CERT_STORE_ADD_NEWER - Imports a certificate only if the certificate is newer than an existing matching certificate. |
7 | CERT_STORE_ADD_NEWER_INHERIT_PROPERTIES - Imports a certificate only if the certificate is newer than an existing matching certificate, and inherits the properties of old certificate it replaces. |
This config can take one of the following values:
2 (cstPFXFile) | The certificate store is the name of a PFX (PKCS12) file containing certificates. |
3 (cstPFXBlob) | The certificate store is a string (binary or base64-encoded) representing a certificate store in PFX (PKCS12) format. |
6 (cstPEMKeyFile) | The certificate store is the name of a PEM-encoded file that contains a private key and an optional certificate. |
7 (cstPEMKeyBlob) | The certificate store is a string (binary or base64-encoded) that contains a private key and an optional certificate. |
8 (cstPublicKeyFile) | The certificate store is the name of a file that contains a PEM- or DER-encoded public key certificate. |
9 (cstPublicKeyBlob) | The certificate store is a string (binary or base64-encoded) that contains a PEM- or DER-encoded public key certificate. |
10 (cstSSHPublicKeyBlob) | The certificate store is a string (binary or base64-encoded) that contains an SSH-style public key. |
13 (cstSSHPublicKeyFile) | The certificate store is the name of a file that contains an SSH-style public key. |
99 (cstAuto - default) | The certificate type is automatically determined from the input. |
Valid values are:
- (empty string)
- HS256
- HS384
- HS512
- RS256
- RS384
- RS512
- EC256
- EC384
- EC512
- EC256K
The default value is False.
This setting format is a JSON array. Examples: ["sign","verify"] or ["encrypt"].
Valid values are enc and sig.
- 0 (PEM - default)
- 1 (XML)
0 (None) | No events are logged. |
1 (Info - default) | Informational events are logged. |
2 (Verbose) | Detailed data are logged. |
3 (Debug) | Debug data are logged. |
string altNames = "email:copy,dns:domain.com,dns.1:other.domain.com,uri:http://www.domain.com,ip:192.168.1.102"
Base Config Settings
The following is a list of valid code page identifiers:
Identifier | Name |
037 | IBM EBCDIC - U.S./Canada |
437 | OEM - United States |
500 | IBM EBCDIC - International |
708 | Arabic - ASMO 708 |
709 | Arabic - ASMO 449+, BCON V4 |
710 | Arabic - Transparent Arabic |
720 | Arabic - Transparent ASMO |
737 | OEM - Greek (formerly 437G) |
775 | OEM - Baltic |
850 | OEM - Multilingual Latin I |
852 | OEM - Latin II |
855 | OEM - Cyrillic (primarily Russian) |
857 | OEM - Turkish |
858 | OEM - Multilingual Latin I + Euro symbol |
860 | OEM - Portuguese |
861 | OEM - Icelandic |
862 | OEM - Hebrew |
863 | OEM - Canadian-French |
864 | OEM - Arabic |
865 | OEM - Nordic |
866 | OEM - Russian |
869 | OEM - Modern Greek |
870 | IBM EBCDIC - Multilingual/ROECE (Latin-2) |
874 | ANSI/OEM - Thai (same as 28605, ISO 8859-15) |
875 | IBM EBCDIC - Modern Greek |
932 | ANSI/OEM - Japanese, Shift-JIS |
936 | ANSI/OEM - Simplified Chinese (PRC, Singapore) |
949 | ANSI/OEM - Korean (Unified Hangul Code) |
950 | ANSI/OEM - Traditional Chinese (Taiwan; Hong Kong SAR, PRC) |
1026 | IBM EBCDIC - Turkish (Latin-5) |
1047 | IBM EBCDIC - Latin 1/Open System |
1140 | IBM EBCDIC - U.S./Canada (037 + Euro symbol) |
1141 | IBM EBCDIC - Germany (20273 + Euro symbol) |
1142 | IBM EBCDIC - Denmark/Norway (20277 + Euro symbol) |
1143 | IBM EBCDIC - Finland/Sweden (20278 + Euro symbol) |
1144 | IBM EBCDIC - Italy (20280 + Euro symbol) |
1145 | IBM EBCDIC - Latin America/Spain (20284 + Euro symbol) |
1146 | IBM EBCDIC - United Kingdom (20285 + Euro symbol) |
1147 | IBM EBCDIC - France (20297 + Euro symbol) |
1148 | IBM EBCDIC - International (500 + Euro symbol) |
1149 | IBM EBCDIC - Icelandic (20871 + Euro symbol) |
1200 | Unicode UCS-2 Little-Endian (BMP of ISO 10646) |
1201 | Unicode UCS-2 Big-Endian |
1250 | ANSI - Central European |
1251 | ANSI - Cyrillic |
1252 | ANSI - Latin I |
1253 | ANSI - Greek |
1254 | ANSI - Turkish |
1255 | ANSI - Hebrew |
1256 | ANSI - Arabic |
1257 | ANSI - Baltic |
1258 | ANSI/OEM - Vietnamese |
1361 | Korean (Johab) |
10000 | MAC - Roman |
10001 | MAC - Japanese |
10002 | MAC - Traditional Chinese (Big5) |
10003 | MAC - Korean |
10004 | MAC - Arabic |
10005 | MAC - Hebrew |
10006 | MAC - Greek I |
10007 | MAC - Cyrillic |
10008 | MAC - Simplified Chinese (GB 2312) |
10010 | MAC - Romania |
10017 | MAC - Ukraine |
10021 | MAC - Thai |
10029 | MAC - Latin II |
10079 | MAC - Icelandic |
10081 | MAC - Turkish |
10082 | MAC - Croatia |
12000 | Unicode UCS-4 Little-Endian |
12001 | Unicode UCS-4 Big-Endian |
20000 | CNS - Taiwan |
20001 | TCA - Taiwan |
20002 | Eten - Taiwan |
20003 | IBM5550 - Taiwan |
20004 | TeleText - Taiwan |
20005 | Wang - Taiwan |
20105 | IA5 IRV International Alphabet No. 5 (7-bit) |
20106 | IA5 German (7-bit) |
20107 | IA5 Swedish (7-bit) |
20108 | IA5 Norwegian (7-bit) |
20127 | US-ASCII (7-bit) |
20261 | T.61 |
20269 | ISO 6937 Non-Spacing Accent |
20273 | IBM EBCDIC - Germany |
20277 | IBM EBCDIC - Denmark/Norway |
20278 | IBM EBCDIC - Finland/Sweden |
20280 | IBM EBCDIC - Italy |
20284 | IBM EBCDIC - Latin America/Spain |
20285 | IBM EBCDIC - United Kingdom |
20290 | IBM EBCDIC - Japanese Katakana Extended |
20297 | IBM EBCDIC - France |
20420 | IBM EBCDIC - Arabic |
20423 | IBM EBCDIC - Greek |
20424 | IBM EBCDIC - Hebrew |
20833 | IBM EBCDIC - Korean Extended |
20838 | IBM EBCDIC - Thai |
20866 | Russian - KOI8-R |
20871 | IBM EBCDIC - Icelandic |
20880 | IBM EBCDIC - Cyrillic (Russian) |
20905 | IBM EBCDIC - Turkish |
20924 | IBM EBCDIC - Latin-1/Open System (1047 + Euro symbol) |
20932 | JIS X 0208-1990 & 0121-1990 |
20936 | Simplified Chinese (GB2312) |
21025 | IBM EBCDIC - Cyrillic (Serbian, Bulgarian) |
21027 | Extended Alpha Lowercase |
21866 | Ukrainian (KOI8-U) |
28591 | ISO 8859-1 Latin I |
28592 | ISO 8859-2 Central Europe |
28593 | ISO 8859-3 Latin 3 |
28594 | ISO 8859-4 Baltic |
28595 | ISO 8859-5 Cyrillic |
28596 | ISO 8859-6 Arabic |
28597 | ISO 8859-7 Greek |
28598 | ISO 8859-8 Hebrew |
28599 | ISO 8859-9 Latin 5 |
28605 | ISO 8859-15 Latin 9 |
29001 | Europa 3 |
38598 | ISO 8859-8 Hebrew |
50220 | ISO 2022 Japanese with no halfwidth Katakana |
50221 | ISO 2022 Japanese with halfwidth Katakana |
50222 | ISO 2022 Japanese JIS X 0201-1989 |
50225 | ISO 2022 Korean |
50227 | ISO 2022 Simplified Chinese |
50229 | ISO 2022 Traditional Chinese |
50930 | Japanese (Katakana) Extended |
50931 | US/Canada and Japanese |
50933 | Korean Extended and Korean |
50935 | Simplified Chinese Extended and Simplified Chinese |
50936 | Simplified Chinese |
50937 | US/Canada and Traditional Chinese |
50939 | Japanese (Latin) Extended and Japanese |
51932 | EUC - Japanese |
51936 | EUC - Simplified Chinese |
51949 | EUC - Korean |
51950 | EUC - Traditional Chinese |
52936 | HZ-GB2312 Simplified Chinese |
54936 | Windows XP: GB18030 Simplified Chinese (4 Byte) |
57002 | ISCII Devanagari |
57003 | ISCII Bengali |
57004 | ISCII Tamil |
57005 | ISCII Telugu |
57006 | ISCII Assamese |
57007 | ISCII Oriya |
57008 | ISCII Kannada |
57009 | ISCII Malayalam |
57010 | ISCII Gujarati |
57011 | ISCII Punjabi |
65000 | Unicode UTF-7 |
65001 | Unicode UTF-8 |
Identifier | Name |
1 | ASCII |
2 | NEXTSTEP |
3 | JapaneseEUC |
4 | UTF8 |
5 | ISOLatin1 |
6 | Symbol |
7 | NonLossyASCII |
8 | ShiftJIS |
9 | ISOLatin2 |
10 | Unicode |
11 | WindowsCP1251 |
12 | WindowsCP1252 |
13 | WindowsCP1253 |
14 | WindowsCP1254 |
15 | WindowsCP1250 |
21 | ISO2022JP |
30 | MacOSRoman |
10 | UTF16String |
0x90000100 | UTF16BigEndian |
0x94000100 | UTF16LittleEndian |
0x8c000100 | UTF32String |
0x98000100 | UTF32BigEndian |
0x9c000100 | UTF32LittleEndian |
65536 | Proprietary |
- Product: The product the license is for.
- Product Key: The key the license was generated from.
- License Source: Where the license was found (e.g., RuntimeLicense, License File).
- License Type: The type of license installed (e.g., Royalty Free, Single Server).
- Last Valid Build: The last valid build number for which the license will work.
This setting only works on these classes: AS3Receiver, AS3Sender, Atom, Client(3DS), FTP, FTPServer, IMAP, OFTPClient, SSHClient, SCP, Server(3DS), Sexec, SFTP, SFTPServer, SSHServer, TCPClient, TCPServer.
Setting this configuration setting to true tells the class to use the internal implementation instead of using the system security libraries.
On Windows, this setting is set to false by default. On Linux/macOS, this setting is set to true by default.
To use the system security libraries for Linux, OpenSSL support must be enabled. For more information on how to enable OpenSSL, please refer to the OpenSSL Notes section.
Trappable Errors (CertMgr Class)
Error Handling (C++)
Call the GetLastErrorCode() method to obtain the last called method's result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. Known error codes are listed below. If an error occurs, the GetLastError() method can be called to retrieve the associated error message.
CertMgr Errors
143 Busy executing current method. | |
144 No certificate selected. | |
221 Cannot acquire CSP. | |
222 Cannot generate key. | |
270 Cannot load specified security library. | |
271 Cannot open certificate store. | |
272 Cannot find specified certificate. | |
274 Cannot get certificate chain. | |
275 Cannot verify certificate chain. | |
279 Error enumerating certificate stores. | |
280 The certificate could not be decoded. | |
281 Cannot find security provider. | |
282 Cannot add certificate to store. | |
283 The certificate could not be encoded. | |
285 Cannot create certificate signing request. | |
286 Cannot acquire Issuer private key. | |
287 Cannot delete certificate. | |
288 Cannot export certificate. |