Skip to content

Commit 65b0b9f

Browse files
dgaleymkachkKeyfactor
authored
Release: 1.0.1
Signed-off-by: Morgan Gangwere <Morgan.gangwere@keyfactor.com> Co-authored-by: Mark Kachkaev <mark.kachkaev@keyfactor.com> Co-authored-by: Keyfactor <keyfactor@keyfactor.github.io>
1 parent e30f109 commit 65b0b9f

10 files changed

Lines changed: 273 additions & 64 deletions

.github/workflows/keyfactor-bootstrap-workflow-v3.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Keyfactor Bootstrap Workflow
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
types: [opened, closed, synchronize, edited, reopened]
7+
push:
8+
create:
9+
branches:
10+
- 'release-*.*'
11+
12+
jobs:
13+
call-starter-workflow:
14+
uses: keyfactor/actions/.github/workflows/starter.yml@v4
15+
permissions:
16+
contents: write # Explicitly grant write permission
17+
with:
18+
command_token_url: ${{ vars.COMMAND_TOKEN_URL }}
19+
command_hostname: ${{ vars.COMMAND_HOSTNAME }}
20+
command_base_api_path: ${{ vars.COMMAND_API_PATH }}
21+
secrets:
22+
token: ${{ secrets.V2BUILDTOKEN}}
23+
gpg_key: ${{ secrets.KF_GPG_PRIVATE_KEY }}
24+
gpg_pass: ${{ secrets.KF_GPG_PASSPHRASE }}
25+
scan_token: ${{ secrets.SAST_TOKEN }}
26+
entra_username: ${{ secrets.DOCTOOL_ENTRA_USERNAME }}
27+
entra_password: ${{ secrets.DOCTOOL_ENTRA_PASSWD }}
28+
command_client_id: ${{ secrets.COMMAND_CLIENT_ID }}
29+
command_client_secret: ${{ secrets.COMMAND_CLIENT_SECRET }}

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<h1 align="center" style="border-bottom: none">
2-
GlobalSign MSSL Gateway AnyCA Gateway REST Plugin
2+
GlobalSign MSSL AnyCA Gateway REST Plugin
33
</h1>
44

55
<p align="center">
@@ -38,10 +38,10 @@ The GlobalSign CAPlugin enables the Synchronization, Enrollment, and Revocation
3838

3939
## Compatibility
4040

41-
The GlobalSign MSSL Gateway AnyCA Gateway REST plugin is compatible with the Keyfactor AnyCA Gateway REST 25.2.0 and later.
41+
The GlobalSign MSSL AnyCA Gateway REST plugin is compatible with the Keyfactor AnyCA Gateway REST 25.2.0 and later.
4242

4343
## Support
44-
The GlobalSign MSSL Gateway AnyCA Gateway REST plugin is supported by Keyfactor for Keyfactor customers. If you have a support issue, please open a support ticket with your Keyfactor representative. If you have a support issue, please open a support ticket via the Keyfactor Support Portal at https://support.keyfactor.com.
44+
The GlobalSign MSSL AnyCA Gateway REST plugin is supported by Keyfactor for Keyfactor customers. If you have a support issue, please open a support ticket with your Keyfactor representative. If you have a support issue, please open a support ticket via the Keyfactor Support Portal at https://support.keyfactor.com.
4545

4646
> 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.
4747
@@ -60,7 +60,7 @@ This extension uses the contact information of the GCC Domain point of contact f
6060

6161
1. Install the AnyCA Gateway REST per the [official Keyfactor documentation](https://software.keyfactor.com/Guides/AnyCAGatewayREST/Content/AnyCAGatewayREST/InstallIntroduction.htm).
6262

63-
2. On the server hosting the AnyCA Gateway REST, download and unzip the latest [GlobalSign MSSL Gateway AnyCA Gateway REST plugin](https://github.com/Keyfactor/globalsign-mssl-caplugin/releases/latest) from GitHub.
63+
2. On the server hosting the AnyCA Gateway REST, download and unzip the latest [GlobalSign MSSL AnyCA Gateway REST plugin](https://github.com/Keyfactor/globalsign-mssl-caplugin/releases/latest) from GitHub.
6464

6565
3. Copy the unzipped directory (usually called `net6.0` or `net8.0`) to the Extensions directory:
6666

@@ -71,11 +71,11 @@ This extension uses the contact information of the GCC Domain point of contact f
7171
Program Files\Keyfactor\AnyCA Gateway\AnyGatewayREST\net8.0\Extensions
7272
```
7373

74-
> The directory containing the GlobalSign MSSL Gateway AnyCA Gateway REST plugin DLLs (`net6.0` or `net8.0`) can be named anything, as long as it is unique within the `Extensions` directory.
74+
> The directory containing the GlobalSign MSSL AnyCA Gateway REST plugin DLLs (`net6.0` or `net8.0`) can be named anything, as long as it is unique within the `Extensions` directory.
7575

7676
4. Restart the AnyCA Gateway REST service.
7777

78-
5. Navigate to the AnyCA Gateway REST portal and verify that the Gateway recognizes the GlobalSign MSSL Gateway plugin by hovering over the ⓘ symbol to the right of the Gateway on the top left of the portal.
78+
5. Navigate to the AnyCA Gateway REST portal and verify that the Gateway recognizes the GlobalSign MSSL plugin by hovering over the ⓘ symbol to the right of the Gateway on the top left of the portal.
7979

8080
## Configuration
8181

@@ -103,8 +103,10 @@ This extension uses the contact information of the GCC Domain point of contact f
103103
* **RetryCount** - This is the number of times the AnyGateway will attempt to pickup an new certificate before reporting an error. Default is 5.
104104
* **SyncIntervalDays** - OPTIONAL: Required if SyncStartDate is used. Specifies how to page the certificate sync. Should be a value such that no interval of that length contains > 500 certificate enrollments.
105105
* **SyncStartDate** - If provided, full syncs will start at the specified date.
106+
* **SyncProducts** - OPTIONAL: If provided as a comma-separated list of product IDs, will limit the certificate sync to only certificates of those products. If blank or not provided, will sync all certs.
107+
* **Enabled** - Flag to Enable or Disable gateway functionality. Disabling is primarily used to allow creation of the CA prior to configuration information being available.
106108

107-
2. Define [Certificate Profiles](https://software.keyfactor.com/Guides/AnyCAGatewayREST/Content/AnyCAGatewayREST/AddCP-Gateway.htm) and [Certificate Templates](https://software.keyfactor.com/Guides/AnyCAGatewayREST/Content/AnyCAGatewayREST/AddCA-Gateway.htm) for the Certificate Authority as required. One Certificate Profile must be defined per Certificate Template. It's recommended that each Certificate Profile be named after the Product ID. The GlobalSign MSSL Gateway plugin supports the following product IDs:
109+
2. Define [Certificate Profiles](https://software.keyfactor.com/Guides/AnyCAGatewayREST/Content/AnyCAGatewayREST/AddCP-Gateway.htm) and [Certificate Templates](https://software.keyfactor.com/Guides/AnyCAGatewayREST/Content/AnyCAGatewayREST/AddCA-Gateway.htm) for the Certificate Authority as required. One Certificate Profile must be defined per Certificate Template. It's recommended that each Certificate Profile be named after the Product ID. The GlobalSign MSSL plugin supports the following product IDs:
108110
109111
* **PEV_SHA2**
110112
* **PEV**
@@ -123,6 +125,8 @@ This extension uses the contact information of the GCC Domain point of contact f
123125
* **CertificateValidityInYears** - Number of years the certificate will be valid for
124126
* **SlotSize** - Maximum number of SANs that a certificate may have - valid values are [FIVE, TEN, FIFTEEN, TWENTY, THIRTY, FOURTY, FIFTY, ONE_HUNDRED]
125127
* **RootCAType** - The certificate's root CA - Depending on certificate expiration date, SHA_1 not be allowed. Will default to SHA_2 if expiration date exceeds sha1 allowed date. Options are GlobalSign R certs.
128+
* **MSSLProfileId** - OPTIONAL: If specified, enrollments will use that profile ID for domain lookups. If not provided, domain lookup will be done based on the Common Name or first DNS SAN. Useful if your GlobalSign account has multiple domain objects with the same domain string, or subdomains (e.g. sub.test.com vs test.com).
129+
* **ContactName** - The name of the contact to use for enrollments. Can be specified here or via an Enrollment Field in Command. Enrollment Fields will override any value supplied here.
126130

127131

128132
## Valid GlobalSign SAN Usage

globalsign-mssl-caplugin/Api/GlobalSignEnrollRequest.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,32 @@ public BmV2PvOrderRequest Request
107107
continue;
108108
}
109109

110-
var entry = new SANEntry();
110+
string trimCN = CommonName, trimItem = item;
111+
112+
if (CommonName.StartsWith("*."))
113+
{
114+
trimCN = CommonName.Substring(2).ToLower();
115+
trimItem = item.ToLower();
116+
List<string> equivs = new List<string> { $"*.{trimCN}", $"www.{trimCN}", $"{trimCN}" };
117+
if (equivs.Contains(trimItem))
118+
{
119+
Logger.LogInformation($"SAN Entry {item} is equivalent to CN ignoring wildcards or www prefix, removing from request");
120+
continue;
121+
}
122+
}
123+
else if (CommonName.StartsWith("www."))
124+
{
125+
trimCN = CommonName.Substring(4).ToLower();
126+
trimItem = item.ToLower();
127+
List<string> equivs = new List<string> { $"www.{trimCN}", $"{trimCN}" };
128+
if (equivs.Contains(trimItem))
129+
{
130+
Logger.LogInformation($"SAN Entry {item} is equivalent to CN ignoring wildcards or www prefix, removing from request");
131+
continue;
132+
}
133+
}
134+
135+
var entry = new SANEntry();
111136
entry.SubjectAltName = item;
112137
var sb = new StringBuilder();
113138
sb.Append("Adding SAN entry of type ");

globalsign-mssl-caplugin/Api/GlobalSignRenewRequest.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,31 @@ public GlobalSignRenewRequest(GlobalSignCAConfig config, bool privateDomain, boo
5353
Logger.LogInformation($"SAN Entry {item} matches CN, removing from request");
5454
continue;
5555
}
56+
string trimCN = CommonName, trimItem = item;
5657

57-
var entry = new SANEntry();
58+
if (CommonName.StartsWith("*."))
59+
{
60+
trimCN = CommonName.Substring(2).ToLower();
61+
trimItem = item.ToLower();
62+
List<string> equivs = new List<string> { $"*.{trimCN}", $"www.{trimCN}", $"{trimCN}" };
63+
if (equivs.Contains(trimItem))
64+
{
65+
Logger.LogInformation($"SAN Entry {item} is equivalent to CN ignoring wildcards or www prefix, removing from request");
66+
continue;
67+
}
68+
}
69+
else if (CommonName.StartsWith("www."))
70+
{
71+
trimCN = CommonName.Substring(4).ToLower();
72+
trimItem = item.ToLower();
73+
List<string> equivs = new List<string> { $"www.{trimCN}", $"{trimCN}" };
74+
if (equivs.Contains(trimItem))
75+
{
76+
Logger.LogInformation($"SAN Entry {item} is equivalent to CN ignoring wildcards or www prefix, removing from request");
77+
continue;
78+
}
79+
}
80+
var entry = new SANEntry();
5881
entry.SubjectAltName = item;
5982
var sb = new StringBuilder();
6083
sb.Append("Adding SAN entry of type ");

globalsign-mssl-caplugin/Client/GlobalSignApiClient.cs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ public GlobalSignApiClient(GlobalSignCAConfig config, ILogger logger)
2626
Logger = logger;
2727
Config = config;
2828
// Logger = LogHandler.GetClassLogger(this.GetType());
29+
var enabled =config.Enabled;
30+
if (!enabled)
31+
{
32+
Logger.LogWarning($"The CA is currently in the Disabled state. It must be Enabled to perform operations. Skipping config validation and MSSL Client creation...");
33+
Logger.MethodExit();
34+
return;
35+
}
2936
QueryService = new GASV1Client
3037
{
3138
Endpoint = { Address = new EndpointAddress(config.GetUrl(GlobalSignServiceType.QUERY)), Name = "QUERY" }
@@ -47,10 +54,8 @@ public async Task<List<OrderDetail>> GetCertificatesForSyncAsync(
4754
var results = new List<OrderDetail>();
4855
if (fullSync)
4956
{
50-
// If startDate is before year 2000, treat it as “since the dawn of time”
51-
var from = startDate > new DateTime(2000, 1, 1)
52-
? startDate
53-
: DateTime.MinValue;
57+
58+
var from = startDate;
5459
var finalStop = DateTime.UtcNow;
5560

5661
// first window
@@ -72,8 +77,12 @@ public async Task<List<OrderDetail>> GetCertificatesForSyncAsync(
7277
}
7378
else
7479
{
75-
// incremental sync since lastSync
80+
// incremental sync since lastSync, unless lastSync is earlier than startDate, then use that
7681
var from = lastSync;
82+
if (from < startDate)
83+
{
84+
from = startDate;
85+
}
7786
var to = DateTime.UtcNow;
7887

7988
results.AddRange(
@@ -272,19 +281,19 @@ public async Task<EnrollmentResult> Enroll(GlobalSignEnrollRequest enrollRequest
272281
Logger.MethodEntry();
273282
var rawRequest = enrollRequest.Request;
274283
Logger.LogTrace("Request details:");
275-
Logger.LogTrace($"Profile ID: {enrollRequest.MsslProfileId}");
276-
Logger.LogTrace($"Domain ID: {enrollRequest.MsslDomainId}");
284+
Logger.LogTrace($"Profile ID: {rawRequest.MSSLProfileID}");
285+
Logger.LogTrace($"Domain ID: {rawRequest.MSSLDomainID}");
277286
Logger.LogTrace(
278-
$"Contact Info: {enrollRequest.FirstName}, {enrollRequest.LastName}, {enrollRequest.Email}, {enrollRequest.Phone}");
279-
Logger.LogTrace($"SAN Count: {enrollRequest.SANs.Count()}");
287+
$"Contact Info: {rawRequest.ContactInfo.FirstName}, {rawRequest.ContactInfo.LastName}, {rawRequest.ContactInfo.Email}, {rawRequest.ContactInfo.Phone}");
288+
Logger.LogTrace($"SAN Count: {rawRequest.SANEntries.Count()}");
280289
if (rawRequest.SANEntries.Count() > 0)
281290
Logger.LogTrace($"SANs: {string.Join(",", rawRequest.SANEntries.Select(s => s.SubjectAltName))}");
282291
Logger.LogTrace($"Product Code: {rawRequest.OrderRequestParameter.ProductCode}");
283292
Logger.LogTrace($"Order Kind: {rawRequest.OrderRequestParameter.OrderKind}");
284293
if (!string.IsNullOrEmpty(rawRequest.OrderRequestParameter.BaseOption))
285294
Logger.LogTrace($"Order Base Option: {rawRequest.OrderRequestParameter.BaseOption}");
286295

287-
var requestwrapper = new PVOrder(enrollRequest.Request);
296+
var requestwrapper = new PVOrder(rawRequest);
288297
var responsewrapper = await OrderService.PVOrderAsync(requestwrapper);
289298
;
290299
var response = responsewrapper.Response;

globalsign-mssl-caplugin/Constants.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,15 @@ internal class Constants
2121
public static string PICKUPDELAY = "DelayTime";
2222
public static string SYNCSTARTDATE = "SyncStartDate";
2323
public static string SYNCINTERNVALDAYS = "SyncIntervalDays";
24+
public static string SYNCPRODUCTS = "SyncProducts";
25+
public static string Enabled = "Enabled";
2426
}
2527

2628
public static class EnrollmentConfigConstants
2729
{
2830
public const string RootCAType = "RootCAType";
2931
public const string SlotSize = "SlotSize";
3032
public const string CertificateValidityInYears = "CertificateValidityInYears";
33+
public const string MSSLProfileId = "MSSLProfileId";
34+
public const string ContactName = "ContactName";
3135
}

globalsign-mssl-caplugin/GlobalSignCAConfig.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ public class GlobalSignCAConfig
3232

3333
public string SyncStartDate { get; set; } = "";
3434
public int SyncIntervalDays { get; set; } = 0;
35+
public string SyncProducts { get; set; } = "";
3536

37+
public bool Enabled { get; set; } = true;
3638

3739
public string GetUrl(GlobalSignServiceType queryType)
3840
{

0 commit comments

Comments
 (0)