Skip to content

Commit 07ba7f9

Browse files
authored
Merge pull request #97 from Keyfactor/52726-Bug_Report_WinRM_OnError
ab#52726 bug report win rm on error
2 parents 7e15ec8 + 50f6a3e commit 07ba7f9

File tree

9 files changed

+92
-97
lines changed

9 files changed

+92
-97
lines changed

.github/workflows/keyfactor-merge-store-types.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 16 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,19 @@
1-
name: Starter Workflow
2-
on: [workflow_dispatch, push, pull_request]
1+
name: Keyfactor Bootstrap Workflow
32

4-
jobs:
5-
call-create-github-release-workflow:
6-
uses: Keyfactor/actions/.github/workflows/github-release.yml@main
7-
8-
get-manifest-properties:
9-
runs-on: windows-latest
10-
outputs:
11-
update_catalog: ${{ steps.read-json.outputs.prop }}
12-
steps:
13-
- uses: actions/checkout@v3
14-
- name: Read json
15-
id: read-json
16-
shell: pwsh
17-
run: |
18-
$json = Get-Content integration-manifest.json | ConvertFrom-Json
19-
echo "::set-output name=prop::$(echo $json.update_catalog)"
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
types: [opened, closed, synchronize, edited, reopened]
7+
push:
8+
create:
9+
branches:
10+
- 'release-*.*'
2011

21-
call-dotnet-build-and-release-workflow:
22-
needs: [call-create-github-release-workflow]
23-
uses: Keyfactor/actions/.github/workflows/dotnet-build-and-release.yml@main
24-
with:
25-
release_version: ${{ needs.call-create-github-release-workflow.outputs.release_version }}
26-
release_url: ${{ needs.call-create-github-release-workflow.outputs.release_url }}
27-
release_dir: IISU/bin/Release/net6.0
28-
secrets:
29-
token: ${{ secrets.PRIVATE_PACKAGE_ACCESS }}
30-
31-
call-generate-readme-workflow:
32-
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
33-
uses: Keyfactor/actions/.github/workflows/generate-readme.yml@main
12+
jobs:
13+
call-starter-workflow:
14+
uses: keyfactor/actions/.github/workflows/starter.yml@v2
3415
secrets:
35-
token: ${{ secrets.APPROVE_README_PUSH }}
36-
37-
call-update-catalog-workflow:
38-
needs: get-manifest-properties
39-
if: needs.get-manifest-properties.outputs.update_catalog == 'True' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
40-
uses: Keyfactor/actions/.github/workflows/update-catalog.yml@main
41-
secrets:
42-
token: ${{ secrets.SDK_SYNC_PAT }}
43-
44-
16+
token: ${{ secrets.V2BUILDTOKEN}}
17+
APPROVE_README_PUSH: ${{ secrets.APPROVE_README_PUSH}}
18+
gpg_key: ${{ secrets.KF_GPG_PRIVATE_KEY }}
19+
gpg_pass: ${{ secrets.KF_GPG_PASSPHRASE }}

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
2.3.1
2+
* Added additional error trapping for WinRM connections to allow actual error on failure.
3+
14
2.3.0
25
* Added Sql Server Binding Support
3-
6+
* Modified WinCert Advanced PrivateKeyAllowed setting from Required to Optional
7+
48
2.2.2
59
* Removed empty constructor to resolve PAM provider error when using WinCert store types
610

IISU/ClientPSCertStoreManager.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,8 @@ public JobResult AddCertificate(string certificateContents, string privateKeyPas
6565
X509KeyStorageFlags.Exportable
6666
);
6767

68-
_logger.LogTrace($"X509 Cert Created With Subject: {x509Cert.SubjectName}");
69-
_logger.LogTrace(
70-
$"Begin Add for Cert Store {$@"\\{_runspace.ConnectionInfo.ComputerName}\{storePath}"}");
68+
_logger.LogDebug($"X509 Cert Created With Subject: {x509Cert.SubjectName}");
69+
_logger.LogDebug($"Begin Add for Cert Store {$@"\\{_runspace.ConnectionInfo.ComputerName}\{storePath}"}");
7170

7271
// Add Certificate
7372
var funcScript = @"
@@ -83,12 +82,13 @@ function InstallPfxToMachineStore([byte[]]$bytes, [string]$password, [string]$st
8382
}";
8483

8584
ps.AddScript(funcScript).AddStatement();
86-
_logger.LogTrace("InstallPfxToMachineStore Statement Added...");
85+
_logger.LogDebug("InstallPfxToMachineStore Statement Added...");
8786

8887
ps.AddCommand("InstallPfxToMachineStore")
8988
.AddParameter("bytes", Convert.FromBase64String(certificateContents))
9089
.AddParameter("password", privateKeyPassword)
9190
.AddParameter("storeName", $@"\\{_runspace.ConnectionInfo.ComputerName}\{storePath}");
91+
9292
_logger.LogTrace("InstallPfxToMachineStore Command Added...");
9393

9494
foreach (var cmd in ps.Commands.Commands)
@@ -100,6 +100,7 @@ function InstallPfxToMachineStore([byte[]]$bytes, [string]$password, [string]$st
100100
_logger.LogTrace("Invoking ps...");
101101
ps.Invoke();
102102
_logger.LogTrace("ps Invoked...");
103+
103104
if (ps.HadErrors)
104105
{
105106
_logger.LogTrace("ps Has Errors");
@@ -119,6 +120,7 @@ function InstallPfxToMachineStore([byte[]]$bytes, [string]$password, [string]$st
119120
_logger.LogTrace("Clearing Commands...");
120121
ps.Commands.Clear();
121122
_logger.LogTrace("Commands Cleared..");
123+
_logger.LogInformation($"Certificate was successfully added to cert store: {storePath}");
122124

123125
return new JobResult
124126
{
@@ -129,6 +131,8 @@ function InstallPfxToMachineStore([byte[]]$bytes, [string]$password, [string]$st
129131
}
130132
catch (Exception e)
131133
{
134+
_logger.LogError($"Error Occurred in ClientPSCertStoreManager.AddCertificate(): {e.Message}");
135+
132136
return new JobResult
133137
{
134138
Result = OrchestratorJobStatusJobResult.Failure,

IISU/ImplementedStoreTypes/Win/Management.cs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -119,26 +119,22 @@ private JobResult performAddition(ManagementJobConfiguration config)
119119
string storePath = config.CertificateStoreDetails.StorePath;
120120
long jobNumber = config.JobHistoryId;
121121

122-
// Setup a new connection to the client machine
123-
//var connectionInfo = new WSManConnectionInfo(new Uri($"{certStoreDetails?.WinRmProtocol}://{config.CertificateStoreDetails.ClientMachine}:{certStoreDetails?.WinRmPort}/wsman"));
124-
//_logger.LogTrace($"WinRm URL: {certStoreDetails?.WinRmProtocol}://{config.CertificateStoreDetails.ClientMachine}:{certStoreDetails?.WinRmPort}/wsman");
125-
126122
if (storePath != null)
127123
{
128-
_logger.LogTrace($"Attempting to get licenses from cert path: {storePath})");
124+
_logger.LogInformation($"Attempting to add certificate to cert store: {storePath}");
129125

130126
ClientPSCertStoreManager manager = new ClientPSCertStoreManager(_logger, myRunspace, jobNumber);
131-
JobResult result = manager.AddCertificate(certificateContents, privateKeyPassword, storePath);
132-
133-
_logger.LogTrace($"Certificate was successfully added to cert store: {storePath})");
127+
return manager.AddCertificate(certificateContents, privateKeyPassword, storePath);
134128
}
135-
136-
return new JobResult
129+
else
137130
{
138-
Result = OrchestratorJobStatusJobResult.Success,
139-
JobHistoryId = config.JobHistoryId,
140-
FailureMessage = ""
141-
};
131+
return new JobResult
132+
{
133+
Result = OrchestratorJobStatusJobResult.Failure,
134+
JobHistoryId = config.JobHistoryId,
135+
FailureMessage = "Store Path is empty or null."
136+
};
137+
}
142138
}
143139
catch (Exception e)
144140
{

README.md

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
12
# WinCertStore Orchestrator
23

34
The Windows Certificate Store Orchestrator Extension implements two certificate store types. 1) “WinCert” which manages certificates in a Windows local machine store, and 2) “IISU” which manages certificates and their bindings in a Windows local machine store that are bound to Internet Information Server (IIS) websites. These extensions replace the now deprecated “IIS” cert store type that ships with Keyfactor Command. The “IISU” extension also replaces the “IISBin” certificate store type from prior versions of this repository. This orchestrator extension is in the process of being renamed from “IIS Orchestrator” as it now supports certificates that are not in use by IIS.
45

56
#### Integration status: Production - Ready for use in production environments.
67

7-
88
## About the Keyfactor Universal Orchestrator Extension
99

1010
This repository contains a Universal Orchestrator Extension which is a plugin to the Keyfactor Universal Orchestrator. Within the Keyfactor Platform, Orchestrators are used to manage “certificate stores” — collections of certificates and roots of trust that are found within and used by various applications.
@@ -13,23 +13,22 @@ The Universal Orchestrator is part of the Keyfactor software distribution and is
1313

1414
The Universal Orchestrator is the successor to the Windows Orchestrator. This Orchestrator Extension plugin only works with the Universal Orchestrator and does not work with the Windows Orchestrator.
1515

16-
1716
## Support for WinCertStore Orchestrator
1817

19-
WinCertStore Orchestrator is supported by Keyfactor for Keyfactor customers. If you have a support issue, please open a support ticket with your Keyfactor representative.
18+
WinCertStore Orchestrator is supported by Keyfactor for Keyfactor customers. If you have a support issue, please open a support ticket via the Keyfactor Support Portal at https://support.keyfactor.com
2019

2120
###### To report a problem or suggest a new feature, use the **[Issues](../../issues)** tab. If you want to contribute actual bug fixes or proposed enhancements, use the **[Pull requests](../../pulls)** tab.
2221

23-
2422
---
2523

2624

25+
---
26+
2727

2828

2929
## Keyfactor Version Supported
3030

3131
The minimum version of the Keyfactor Universal Orchestrator Framework needed to run this version of the extension is 10.1
32-
3332
## Platform Specific Notes
3433

3534
The Keyfactor Universal Orchestrator may be installed on either Windows or Linux based platforms. The certificate operations supported by a capability may vary based what platform the capability is installed on. The table below indicates what capabilities are supported based on which platform the encompassing Universal Orchestrator is running.
@@ -124,6 +123,27 @@ In version 2.0 of the IIS Orchestrator, the certificate store type has been rena
124123

125124
**Note: If Looking to use GMSA Accounts to run the Service Kefyactor Command 10.2 or greater is required for No Value checkbox to work**
126125

126+
## Security and Permission Considerations
127+
From an official support point of view, Local Administrator permissions are required on the target server. Some customers have been successful with using other accounts and granting rights to the underlying certificate and private key stores. Due to complexities with the interactions between Group Policy, WinRM, User Account Control, and other unpredictable customer environmental factors, Keyfactor cannot provide assistance with using accounts other than the local administrator account.
128+
129+
For customers wishing to use something other than the local administrator account, the following information may be helpful:
130+
131+
* The WinCert extensions (WinCert, IISU, WinSQL) create a WinRM (remote PowerShell) session to the target server in order to manipulate the Windows Certificate Stores, perform binding (in the case of the IISU extension), or to access the registry (in the case of the WinSQL extension).
132+
133+
* When the WinRM session is created, the certificate store credentials are used if they have been specified, otherwise the WinRM session is created in the context of the Universal Orchestrator (UO) Service account (which potentially could be the network service account, a regular account, or a GMSA account)
134+
135+
* WinRM needs to be properly set up between the server hosting the UO and the target server. This means that a WinRM client running on the UO server when running in the context of the UO service account needs to be able to create a session on the target server using the configured credentials of the target server and any PowerShell commands running on the remote session need to have appropriate permissions.
136+
137+
* Even though a given account may be in the administrators group or have administrative privledges on the target system and may be able to execute certificate and binding operations when running locally, the same account may not work when being used via WinRM. User Account Control (UAC) can get in the way and filter out administrative privledges. UAC / WinRM configuration has a LocalAccountTokenFilterPolicy setting that can be adjusted to not filter out administrative privledges for remote users, but enabling this may have other security ramifications.
138+
139+
* The following list may not be exhaustive, but in general the account (when running under a remote WinRM session) needs permissions to:
140+
- Instantiate and open a .NET X509Certificates.X509Store object for the target certificate store and be able to read and write both the certificates and related private keys. Note that ACL permissions on the stores and private keys are separate.
141+
- Use the Import-Certificate, Get-WebSite, Get-WebBinding, and New-WebBinding PowerShell CmdLets.
142+
- Create and delete temporary files.
143+
- Execute certreq commands.
144+
- Access any Cryptographic Service Provider (CSP) referenced in re-enrollment jobs.
145+
- Read and Write values in the registry (HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server) when performing SQL Server certificate binding.
146+
127147
## Creating New Certificate Store Types
128148
Currently this orchestrator handles two extensions: IISU for IIS servers with bound certificates and WinCert for general Windows Certificates.
129149
Below describes how each of these certificate store types are created and configured.
@@ -155,7 +175,7 @@ CONFIG ELEMENT | VALUE | DESCRIPTION
155175
Store Path Type | Multiple Choice | Determines what restrictions are applied to the store path field when configuring a new store.
156176
Store Path Value | My,WebHosting | Comma separated list of options configure multiple choice. This, combined with the hostname, will determine the location used for the certificate store management and inventory.
157177
Supports Custom Alias | Forbidden | Determines if an individual entry within a store can have a custom Alias.
158-
Private Keys | Required | This determines if Keyfactor can send the private key associated with a certificate to the store. Required because IIS certificates without private keys would be useless.
178+
Private Keys | Required | This determines if Keyfactor can send the private key associated with a certificate to the store. Required because IIS certificates without private keys would be invalid.
159179
PFX Password Style | Default or Custom | "Default" - PFX password is randomly generated, "Custom" - PFX password may be specified when the enrollment job is created (Requires the *Allow Custom Password* application setting to be enabled.)
160180

161181
![](images/IISUCertStoreAdv.png)
@@ -297,7 +317,7 @@ CONFIG ELEMENT | VALUE | DESCRIPTION
297317
--|--|--
298318
Store Path Type | Freeform | Allows users to type in a valid certificate store.
299319
Supports Custom Alias | Forbidden | Determines if an individual entry within a store can have a custom Alias.
300-
Private Keys | Required | This determines if Keyfactor can send the private key associated with a certificate to the store. Required because IIS certificates without private keys would be useless.
320+
Private Keys | Optional | This determines if Keyfactor can send the private key associated with a certificate to the store. Typically the personal store would have private keys, whereas trusted root would not.
301321
PFX Password Style | Default or Custom | "Default" - PFX password is randomly generated, "Custom" - PFX password may be specified when the enrollment job is created (Requires the *Allow Custom Password* application setting to be enabled.)
302322

303323
![](images/WinCertAdvanced.png)

images/WinCertAdvanced.png

-5 Bytes
Loading

integration-manifest.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
"name": "WinCertStore Orchestrator",
55
"status": "production",
66
"link_github": true,
7+
"release_dir": "IISU/bin/Release/net6.0",
78
"update_catalog": true,
89
"support_level": "kf-supported",
910
"description": "The Windows Certificate Store Orchestrator Extension implements two certificate store types. 1) “WinCert” which manages certificates in a Windows local machine store, and 2) “IISU” which manages certificates and their bindings in a Windows local machine store that are bound to Internet Information Server (IIS) websites. These extensions replace the now deprecated “IIS” cert store type that ships with Keyfactor Command. The “IISU” extension also replaces the “IISBin” certificate store type from prior versions of this repository. This orchestrator extension is in the process of being renamed from “IIS Orchestrator” as it now supports certificates that are not in use by IIS.",
1011
"about": {
1112
"orchestrator": {
1213
"UOFramework": "10.1",
1314
"pam_support": true,
15+
"keyfactor_platform_version": "9.10",
1416
"win": {
1517
"supportsCreateStore": false,
1618
"supportsDiscovery": false,
@@ -415,4 +417,4 @@
415417
]
416418
}
417419
}
418-
}
420+
}

0 commit comments

Comments
 (0)