From 9d5f30a0178ba480b94806f42bcec0c550fd5a3f Mon Sep 17 00:00:00 2001 From: Bevan Weiss Date: Sat, 25 Jan 2025 19:56:36 +1100 Subject: [PATCH] IIS Ext: Add support for more certificate stores Fixes wixtoolset/issues#1520 Signed-off-by: Bevan Weiss --- src/ext/Iis/ca/scacert.cpp | 15 +++++++++++++++ src/ext/Iis/ca/scacert.h | 5 +++++ src/ext/Iis/wixext/IIsCompiler.cs | 15 +++++++++++++++ src/ext/Iis/wixext/IisTableDefinitions.cs | 2 +- 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/ext/Iis/ca/scacert.cpp b/src/ext/Iis/ca/scacert.cpp index ce7968e62..953c813ed 100644 --- a/src/ext/Iis/ca/scacert.cpp +++ b/src/ext/Iis/ca/scacert.cpp @@ -213,6 +213,21 @@ static HRESULT ConfigureCertificates( case SCA_CERTSYSTEMSTORE_LOCALMACHINE: dwStoreLocation = CERT_SYSTEM_STORE_LOCAL_MACHINE; break; + case SCA_CERTSYSTEMSTORE_SERVICES: + dwStoreLocation = CERT_SYSTEM_STORE_SERVICES; + break; + case SCA_CERTSYSTEMSTORE_USERS: + dwStoreLocation = CERT_SYSTEM_STORE_USERS; + break; + case SCA_CERTSYSTEMSTORE_USER_POLICY: + dwStoreLocation = CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY; + break; + case SCA_CERTSYSTEMSTORE_LOCALMACHINE_POLICY: + dwStoreLocation = CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY; + break; + case SCA_CERTSYSTEMSTORE_LOCALMACHINE_ENTERPRISE: + dwStoreLocation = CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE; + break; default: hr = E_INVALIDARG; ExitOnFailure(hr, "Invalid store location value: %d", iData); diff --git a/src/ext/Iis/ca/scacert.h b/src/ext/Iis/ca/scacert.h index 39b00d3d2..6ce5ac729 100644 --- a/src/ext/Iis/ca/scacert.h +++ b/src/ext/Iis/ca/scacert.h @@ -20,4 +20,9 @@ enum SCA_CERTSYSTEMSTORE { SCA_CERTSYSTEMSTORE_CURRENTUSER = 1, SCA_CERTSYSTEMSTORE_LOCALMACHINE = 2, + SCA_CERTSYSTEMSTORE_SERVICES = 3, + SCA_CERTSYSTEMSTORE_USERS = 4, + SCA_CERTSYSTEMSTORE_USER_POLICY = 5, + SCA_CERTSYSTEMSTORE_LOCALMACHINE_POLICY = 6, + SCA_CERTSYSTEMSTORE_LOCALMACHINE_ENTERPRISE = 7, }; diff --git a/src/ext/Iis/wixext/IIsCompiler.cs b/src/ext/Iis/wixext/IIsCompiler.cs index 1fcf5f61c..5e3c0a95b 100644 --- a/src/ext/Iis/wixext/IIsCompiler.cs +++ b/src/ext/Iis/wixext/IIsCompiler.cs @@ -202,6 +202,21 @@ private void ParseCertificateElement(Intermediate intermediate, IntermediateSect case "localMachine": storeLocation = 2; // SCA_CERTSYSTEMSTORE_LOCALMACHINE break; + case "services": + storeLocation = 3; // SCA_CERTSYSTEMSTORE_SERVICES + break; + case "users": + storeLocation = 4; // SCA_CERTSYSTEMSTORE_USERS + break; + case "userPolicy": + storeLocation = 5; // SCA_CERTSYSTEMSTORE_USER_POLICY + break; + case "localMachinePolicy": + storeLocation = 6; // SCA_CERTSYSTEMSTORE_LOCALMACHINE_POLICY + break; + case "localMachineEnterprise": + storeLocation = 7; // SCA_CERTSYSTEMSTORE_LOCALMACHINE_ENTERPRISE + break; default: storeLocation = -1; this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, element.Name.LocalName, "StoreLocation", storeLocationValue, "currentUser", "localMachine")); diff --git a/src/ext/Iis/wixext/IisTableDefinitions.cs b/src/ext/Iis/wixext/IisTableDefinitions.cs index df3edf1d1..1adb781a8 100644 --- a/src/ext/Iis/wixext/IisTableDefinitions.cs +++ b/src/ext/Iis/wixext/IisTableDefinitions.cs @@ -14,7 +14,7 @@ public static class IisTableDefinitions new ColumnDefinition("Certificate", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, keyColumn: 1, description: "Identifier for the certificate in the package.", modularizeType: ColumnModularizeType.Column), new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, description: "Foreign key into the Component table used to determine install state", modularizeType: ColumnModularizeType.Column), new ColumnDefinition("Name", ColumnType.String, 255, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "Name to be used for the Certificate."), - new ColumnDefinition("StoreLocation", ColumnType.Number, 2, primaryKey: false, nullable: false, ColumnCategory.Unknown, minValue: 1, maxValue: 2, description: "Location of the target certificate store (CurrentUser == 1, LocalMachine == 2)"), + new ColumnDefinition("StoreLocation", ColumnType.Number, 2, primaryKey: false, nullable: false, ColumnCategory.Unknown, minValue: 1, maxValue: 7, description: "Location of the target certificate store (CurrentUser == 1, LocalMachine == 2, Services == 3, Users == 4, User Group Policy == 5, LocalMachine Group Policy == 6, LocalMachine Enterprise == 7)"), new ColumnDefinition("StoreName", ColumnType.String, 64, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "Name of the target certificate store"), new ColumnDefinition("Attributes", ColumnType.Number, 4, primaryKey: false, nullable: false, ColumnCategory.Unknown, minValue: 0, maxValue: 2147483647, description: "Attributes of the certificate"), new ColumnDefinition("Binary_", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "Binary", keyColumn: 1, description: "Identifier to Binary table containing certificate.", modularizeType: ColumnModularizeType.Column),