Skip to content

Instantly share code, notes, and snippets.

@x3mxray
Last active November 23, 2022 16:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save x3mxray/0e4805002de6f43f5732c44f5de23d23 to your computer and use it in GitHub Desktop.
Save x3mxray/0e4805002de6f43f5732c44f5de23d23 to your computer and use it in GitHub Desktop.
install_iis_certificate
{
"Parameters": {
"CertificateName": {
"Type": "String",
"Description": "The name of the certificate to be created.",
"DefaultValue": ""
},
"CertPath": {
"Type": "String",
"Description": "The physical path on disk where certificates will be stored.",
"DefaultValue": "C:\\certificates"
},
"RootCertFileName": {
"Type": "String",
"Description": "The file name of the root certificate to be created.",
"DefaultValue": "SitecoreRootCert"
},
"ExportPassword": {
"Type": "String",
"Description": "Password to export certificates with.",
"DefaultValue": "SIF-Default"
}
},
"Variables": {
"Root.Cert.DnsName": "[concat('DO_NOT_TRUST_', parameter('RootCertFileName'))]",
"Root.Cert.Store": "Cert:\\LocalMachine\\Root",
"Client.Cert.Store": "Cert:\\LocalMachine\\My",
"Export.Password": "[if(variable('User.Supplied.Password'),variable('Secure.Password'),variable('Convert.User.Password'))]",
"User.Supplied.Password": "[equal(parameter('ExportPassword'),'SIF-Default')]",
"Secure.Password": "[ConvertToSecureString(String:variable('Password.String'),AsPlainText:true,Force:true)]",
"Password.String": "[RandomString(Length:20,EnforceComplexity:True)]",
"Convert.User.Password": "[ConvertToSecureString(String:parameter('ExportPassword'),AsPlainText:true,Force:true)]"
},
"Register": {
"Tasks": {
"WriteInformation": "Write-Information"
},
"ConfigFunction": {
"ConvertToSecureString": "ConvertTo-SecureString"
}
},
"Tasks": {
"CreatePaths": {
"Description": "Create the physical disk path.",
"Type": "EnsurePath",
"Params": {
"Exists": [
"[parameter('CertPath')]"
]
}
},
"DisplayPassword": {
"Description": "Print password if the user hasn't supplied their own.",
"Type": "WriteInformation",
"Params": {
"Messagedata": "[concat('Certificate Password: ',variable('Password.String'))]",
"InformationAction": "Continue"
},
"Skip": "[not(variable('User.Supplied.Password'))]"
},
"CreateRootCert": {
"Description": "Create the root certificate.",
"Type": "NewRootCertificate",
"Params": {
"Path": "[parameter('CertPath')]",
"Name": "[parameter('RootCertFileName')]",
"DnsName": [
"[variable('Root.Cert.DnsName')]",
"127.0.0.1"
],
"IncludePrivateKey": true,
"Password": "[variable('Export.Password')]"
}
},
"CreateSignedCert": {
"Description": "Create a certificate signed by the root authority.",
"Type": "NewSignedCertificate",
"Params": {
"Signer": "[GetCertificate(variable('Root.Cert.DnsName'), variable('Root.Cert.Store'))]",
"Path": "[parameter('CertPath')]",
"CertStoreLocation": "[variable('Client.Cert.Store')]",
"Name": "[parameter('CertificateName')]",
"DnsName": [
"[parameter('CertificateName')]",
"127.0.0.1"
],
"IncludePrivateKey": true,
"Password": "[variable('Export.Password')]"
}
}
}
}
# Path to this folder
$folderRoot = "C:\Users\sba\Desktop\install_iis_certificate"
$installParams = @{
Path = "$folderRoot\parameters.json"
CertificateName = "sitecore.tracking.collection.service"
CertificatePassword = "b"
}
Push-Location $folderRoot
Install-SitecoreConfiguration @installParams *>&1 | Tee-Object install.log
Pop-Location
{
"Parameters": {
"CertificateName": {
"Type": "String",
"Description": "The name of the certificate to be created.",
"DefaultValue": ""
},
"CertificatePassword": {
"Type": "String",
"Description": "The password of the certificate to be created.",
"DefaultValue": ""
},
"ServerCertificates:CertificateName": {
"Type": "String",
"Reference": "CertificateName",
"Description": "Override to pass IdentityServerCertificateName value to ServerCertificates config."
},
"ServerCertificates:ExportPassword": {
"Type": "String",
"Reference": "CertificatePassword",
"Description": "Override to pass ExportPassword value to CertificatePassword config."
}
},
"Includes" : {
"ServerCertificates":{
"Source": ".\\createcert.json"
}
},
"Register": {
"Tasks": {
"OutNull": "Out-Null"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment