few-lizard-48557
09/13/2022, 7:56 AMimport * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure-native";
import * as rg from "./resource-group";
//////////////////////////////////////////////////////////////////////////////
// Azure Config variables
//////////////////////////////////////////////////////////////////////////////
const config = new pulumi.Config();
const appGatewayName = config.require("appGatewayName");
const sslCertPassword = config.requireSecret("sslCertPassword");
//////////////////////////////////////////////////////////////////////////////
// Create Azure Application Gateway
//////////////////////////////////////////////////////////////////////////////
const applicationGateway = new azure.network.ApplicationGateway(appGatewayName, {
applicationGatewayName: appGatewayName,
authenticationCertificates: [],
location: "westeurope",
resourceGroupName: rg.rgName,
//....
sslCertificates: [{
data: "*****",
name: "my-domain",
password: sslCertPassword,
}],
//....
//....
});
Here I need values for the properties:
'data' => Base-64 encoded pfx certificate
'name' => Name of the SSL certificate (domain name)
'password' => Password for the pfx file specified in data
I have the following values available:
- pfx file
- domain name
- password for pfx file
If I assign the certificate (pfx file) the values via Azure Portal, then the HTTPS connection works correctly.
But unfortunately I cannot assign the certificate/pfx file via code. How do I get from the pfx file to the data or the format I need for the 'data' property - Any help or example is appreciated!import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure-native";
import * as fs from 'fs';
import * as rg from "./resource-group";
//////////////////////////////////////////////////////////////////////////////
// Azure Config variables
//////////////////////////////////////////////////////////////////////////////
const config = new pulumi.Config();
const appGatewayName = config.require("appGatewayName");
const sslCertPassword = config.requireSecret("sslCertPassword");
const sslGetCertData = (() => {
var bitmap = fs.readFileSync('my-domain.pfx');
return bitmap.toString('base64');
})()
//////////////////////////////////////////////////////////////////////////////
// Create Azure AppSettings (for AppServices)
//////////////////////////////////////////////////////////////////////////////
const applicationGateway = new azure.network.ApplicationGateway(appGatewayName, {
applicationGatewayName: appGatewayName,
authenticationCertificates: [],
location: "westeurope",
resourceGroupName: rg.rgName,
//....
sslCertificates: [{
data: sslGetCertData,
name: "my-domain",
password: sslCertPassword,
}],
//....
//....
});