Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 48 additions & 45 deletions IISU.sln
Original file line number Diff line number Diff line change
@@ -1,45 +1,48 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.2.32616.157
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IISU", "IISU\IISU.csproj", "{33FBC5A1-3466-4F10-B9A6-7186F804A65A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{1A6C93E7-24FD-47FD-883D-EDABF5CEE4C6}"
ProjectSection(SolutionItems) = preProject
CHANGELOG.md = CHANGELOG.md
integration-manifest.json = integration-manifest.json
.github\workflows\keyfactor-extension-release.yml = .github\workflows\keyfactor-extension-release.yml
readme_source.md = readme_source.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "images", "images", "{6302034E-DF8C-4B65-AC36-CED24C068999}"
ProjectSection(SolutionItems) = preProject
images\ReEnrollment1.png = images\ReEnrollment1.png
images\ReEnrollment1a.png = images\ReEnrollment1a.png
images\ReEnrollment1b.png = images\ReEnrollment1b.png
images\Screen1.png = images\Screen1.png
images\Screen2.png = images\Screen2.png
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{33FBC5A1-3466-4F10-B9A6-7186F804A65A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{33FBC5A1-3466-4F10-B9A6-7186F804A65A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{33FBC5A1-3466-4F10-B9A6-7186F804A65A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{33FBC5A1-3466-4F10-B9A6-7186F804A65A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{6302034E-DF8C-4B65-AC36-CED24C068999} = {1A6C93E7-24FD-47FD-883D-EDABF5CEE4C6}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E0FA12DA-6B82-4E64-928A-BB9965E636C1}
EndGlobalSection
EndGlobal

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.32929.386
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IISU", "IISU\IISU.csproj", "{33FBC5A1-3466-4F10-B9A6-7186F804A65A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{1A6C93E7-24FD-47FD-883D-EDABF5CEE4C6}"
ProjectSection(SolutionItems) = preProject
CHANGELOG.md = CHANGELOG.md
integration-manifest.json = integration-manifest.json
.github\workflows\keyfactor-extension-release.yml = .github\workflows\keyfactor-extension-release.yml
readme_source.md = readme_source.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "images", "images", "{6302034E-DF8C-4B65-AC36-CED24C068999}"
ProjectSection(SolutionItems) = preProject
images\AddCertStore.png = images\AddCertStore.png
images\CertStoreType-c.png = images\CertStoreType-c.png
images\CertStoreType.png = images\CertStoreType.png
images\ReEnrollment1.png = images\ReEnrollment1.png
images\ReEnrollment1a.png = images\ReEnrollment1a.png
images\ReEnrollment1b.png = images\ReEnrollment1b.png
images\Screen1.png = images\Screen1.png
images\Screen2.png = images\Screen2.png
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{33FBC5A1-3466-4F10-B9A6-7186F804A65A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{33FBC5A1-3466-4F10-B9A6-7186F804A65A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{33FBC5A1-3466-4F10-B9A6-7186F804A65A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{33FBC5A1-3466-4F10-B9A6-7186F804A65A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{6302034E-DF8C-4B65-AC36-CED24C068999} = {1A6C93E7-24FD-47FD-883D-EDABF5CEE4C6}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E0FA12DA-6B82-4E64-928A-BB9965E636C1}
EndGlobalSection
EndGlobal
16 changes: 15 additions & 1 deletion IISU/IISManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
using System;
// Copyright 2022 Keyfactor
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Linq;
using System.Management.Automation;
using System.Management.Automation.Runspaces;
Expand Down
16 changes: 15 additions & 1 deletion IISU/JobProperties.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
using System.ComponentModel;
// Copyright 2022 Keyfactor
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System.ComponentModel;
using Newtonsoft.Json;

namespace Keyfactor.Extensions.Orchestrator.IISU
Expand Down
14 changes: 14 additions & 0 deletions IISU/Jobs/Inventory.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright 2022 Keyfactor
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Collections.Generic;
using System.Linq;
Expand Down
16 changes: 15 additions & 1 deletion IISU/Jobs/Management.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
using System;
// Copyright 2022 Keyfactor
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Linq;
using System.Management.Automation;
using System.Management.Automation.Runspaces;
Expand Down
29 changes: 24 additions & 5 deletions IISU/Jobs/ReEnrollment.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
using System;
// Copyright 2022 Keyfactor
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Management.Automation;
Expand Down Expand Up @@ -108,15 +122,20 @@ private JobResult PerformReEnrollment(ReenrollmentJobConfiguration config, Submi
ps.AddScript($"Add-Content $infFilename '[Extensions]'");
ps.AddScript(@"Add-Content $infFilename '2.5.29.17 = ""{text}""'");

// Todo: Parse SAN by '&' and add the below entry for each DSN
foreach (string s in SAN.ToString().Split("&"))
{
ps.AddScript($"Add-Content $infFilename '_continue_ = \"{s + "&"}\"'");
}

// Execute the -new command
ps.AddScript($"certreq -new -q $infFilename $csrFilename");
_logger.LogDebug($"Subject Text: {subjectText}");
_logger.LogDebug($"SAN: {SAN}");
_logger.LogDebug($"Provider Name: {providerName}");
_logger.LogDebug($"Key Type: {keyType}");
_logger.LogDebug($"Key Size: {keySize}");
_logger.LogTrace("Attempting to create the CSR by Invoking the script.");

Collection<PSObject> results = ps.Invoke();
_logger.LogTrace("Completed the attempt in creating the CSR.");
ps.Commands.Clear();
Expand All @@ -126,9 +145,9 @@ private JobResult PerformReEnrollment(ReenrollmentJobConfiguration config, Submi
ps.AddScript($"$CSR = Get-Content $csrFilename");
_logger.LogTrace("Attempting to get the contents of the CSR file.");
results = ps.Invoke();
_logger.LogTrace("Completet getting the CSR Contents.");
_logger.LogTrace("Finished getting the CSR Contents.");
}
catch (Exception e)
catch (Exception)
{
var psError = ps.Streams.Error.ReadAll().Aggregate(String.Empty, (current, error) => current + error.ErrorDetails.Message);
throw new PowerShellCertException($"Error creating CSR File. {psError}");
Expand Down Expand Up @@ -174,7 +193,7 @@ private JobResult PerformReEnrollment(ReenrollmentJobConfiguration config, Submi
_logger.LogTrace("Attempting to accept or bind the certificate to the HSM.");
ps.AddScript("certreq -accept $cerFilename");
ps.Invoke();
_logger.LogTrace("Successfully bind the certificate to the HSM.");
_logger.LogTrace("Successfully bound the certificate to the HSM.");
ps.Commands.Clear();

// Delete the temp files
Expand Down
16 changes: 15 additions & 1 deletion IISU/PSCertStoreException.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
using System;
// Copyright 2022 Keyfactor
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Runtime.Serialization;

namespace Keyfactor.Extensions.Orchestrator.IISU
Expand Down
16 changes: 15 additions & 1 deletion IISU/PSCertificate.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
using System;
// Copyright 2022 Keyfactor
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;

namespace Keyfactor.Extensions.Orchestrator.IISU
{
Expand Down
16 changes: 15 additions & 1 deletion IISU/PowerShellCertException.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
using System;
// Copyright 2022 Keyfactor
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;
Expand Down
18 changes: 16 additions & 2 deletions IISU/PowerShellCertStore.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
using System;
// Copyright 2022 Keyfactor
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Collections.Generic;
using System.Management.Automation;
using System.Management.Automation.Runspaces;
Expand Down Expand Up @@ -50,7 +64,7 @@ private void Initalize()
{
using var ps = PowerShell.Create();
ps.Runspace = RunSpace;
//todo: accept StoreType and Store Name enum for which to open

var certStoreScript = $@"
$certStore = New-Object System.Security.Cryptography.X509Certificates.X509Store('{StorePath}','LocalMachine')
$certStore.Open('ReadOnly')
Expand Down
Loading