MakeSelfSignedCertificate
| Description: | Creates a new self-signed certificate. |
| Returns: | Buffer. The SHA1 thumbprint of the new certificate. |
Usage: ![]() |
Script Only. |
| Function Groups: | Certificates |
| Related to: | AddCertificate | CheckCertificateChain | FindCertificate | GetCertificateInfo | ListCertificates | RemoveCertificate | SetCertificateProperty |
Format: ![]() |
MakeSelfSignedCertificate(MachineStore, StoreName, Subject [, KeyAlgorithm, HashAlgorithm, ValidityPeriod, KeyStrength, KeyUsage, EKU, SAN]) |
| Parameters: |
|
MachineStore |
| Required Boolean. If TRUE (non-zero) attempts to find the certificate in a store in the Local Computer certificate hive. If FALSE (zero) attempts to find a certificate in a store in the Current User certificate hive. |
| StoreName |
| Required text. The name of the store in which to search for the certificate. |
| Subject |
| Required text. The subject that will be written into the certificate. |
| KeyAlgorithm |
| Optional text. The name of the algorithm used with the public / private key pair and to sign the certificate. |
| HashAlgorithm |
| Optional text. The name of the algorithm used to hash the certificate prior to signing. |
| ValidityPeriod |
| Optional numeric. The number of days for which the new certificate will be valid. |
| KeyStrength |
| Optional numeric. The key strength in bits. |
| KeyUsage |
| Optional numeric. The permitted usages for the private / public key pair. |
| EKU |
| Optional text or array of text values. The Extended Key Usages permitted for the private / public key pair. |
| SAN |
| Optional text or array of text values. A set of Subject Alternative Names to be written into the certificate. |
Example:
SANArray = New(2);
SANArray[0] = "URL=urn:localhost:Trihedral:VTScada:MyApplication";
SANArray[1] = "DNS=demoserver.trihedral.com";
NewCertThumbprint = MakeSelfsignedCertificate(FALSE,
"My",
"CN=LPoint;O=Trihedral"
"RSA",
"SHA256",
90,
2048,
#KeyUsageSignature +
#KeyUsageNonRepudiation +
#KeyUsageKeyEncipherment +
#KeyUsageDataEncipherment,
"1.3.6.1.5.5.7.3.2",
SANArray);
This will create a self-signed certificate in the current user’s Personal store with a 2048-bit RSA private/public key pair, hashed with a SHA256 algorithm (and then signed RSA key). The certificate name will be LPoint, the organization name Trihedral and it will be valid for 90 days from today. The public key is intended for client authentication and should only be used for signing, non-repudiation, key and enciphering data. The SAN will hold one URL and one DNS entry.
