I am trying to run terraform using Azure Service Principal, I am trying to do this with certificate, now I have pfx file and it's password, I converted this in pem and logged in via command line to test if cert is working which is the case, now when I try to run terraform with pfx I get the following errors
Error building ARM Config: 1 error occurred: │ * the Client Certificate Path is not a valid pfx file: pkcs12: unknown digest algorithm: 2.16.840.1.101.3.4.2.1
or
Error building ARM Config: 1 error occurred: │ * the Client Certificate Path is not a valid pfx file: pkcs12: expected exactly two safe bags in the PFX PDU
this is my providers.tf
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "3.75.0"
}
null = {
source = "hashicorp/null"
}
}
backend "azurerm" {
resource_group_name = "xxxxxxxx"
storage_account_name = "xxxxxxxxx"
container_name = "tfstate"
key = "terraform.tfstate"
client_id = "xxxxxxxxxxxxxxxxxxxxxxxxxx"
tenant_id = "xxxxxxxxxxxxxxxxxxx"
client_certificate_path = "/cert.pfx"
client_certificate_password = "xxxxxxxxxxxxxxxx"
subscription_id = "xxxxxxxxxxxxxxxxxx"
}
}
provider "azurerm" {
features {}
skip_provider_registration = true
}```
The errors encountered with Terraform and Azure likely stem from issues with the format or processing of your PFX (PKCS#12) certificate file. Such errors commonly occur when the certificate is not in the expected format, or when terraform does not completely support the specific cryptographic elements, such as algorithms, used in your certificate.
Make sure you uploaded the correct
.cercertificate to the respective service principal and correct path to.pfxlocation so that will eliminate the un-necessary errors.My terraform code:
Deployment succeeded: