Skip to content

Commit

Permalink
more san fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dgaley committed Apr 26, 2024
1 parent 5ddeba7 commit 900fd63
Showing 1 changed file with 33 additions and 9 deletions.
42 changes: 33 additions & 9 deletions src/GlobalSignCAProxy/Api/GlobalSignEnrollRequest.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
// Copyright 2021 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.

// Copyright 2021 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 CSS.Common.Logging;

using Keyfactor.Extensions.AnyGateway.GlobalSign.Services.Order;

using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Keyfactor.Extensions.AnyGateway.GlobalSign.Api
{
public class GlobalSignEnrollRequest
public class GlobalSignEnrollRequest : LoggingClientBase
{
internal GlobalSignCAConfig Config;

Expand Down Expand Up @@ -81,21 +85,40 @@ public BmV2PvOrderRequest Request
List<SANEntry> sans = new List<SANEntry>();
foreach (string item in SANs)
{
if (string.Equals(item, CommonName, System.StringComparison.OrdinalIgnoreCase))
{
Logger.Info($"SAN Entry {item} matches CN, removing from request");
continue;
}
SANEntry entry = new SANEntry();
entry.SubjectAltName = item;
StringBuilder sb = new StringBuilder();
sb.Append($"Adding SAN entry of type ");
if (item.StartsWith("*"))
{
entry.SANOptionType = "13";
sb.Append("WILDCARD");
}
else
{
entry.SANOptionType = "7";
sb.Append("FQDN");
}
sb.Append($" and value {item} to request");
Logger.Info(sb.ToString());
sans.Add(entry);
}
request.SANEntries = sans.ToArray();
}
}
List<Option> options = new List<Option>();
if (request.SANEntries.Count() > 0)
{
var opt = new Option();
opt.OptionName = "SAN";
opt.OptionValue = "True";
options.Add(opt);
}
ValidityPeriod validityPeriod = new ValidityPeriod();
validityPeriod.Months = Months;
request.OrderRequestParameter = new OrderRequestParameter
Expand All @@ -104,7 +127,8 @@ public BmV2PvOrderRequest Request
OrderKind = OrderKind,
Licenses = Licenses,
CSR = CSR,
ValidityPeriod = validityPeriod
ValidityPeriod = validityPeriod,
Options = options.ToArray()
};
if (!string.IsNullOrEmpty(BaseOption))
{
Expand Down

0 comments on commit 900fd63

Please sign in to comment.