From e7925cccdaa30bd6db95970fd7623301baa5fb04 Mon Sep 17 00:00:00 2001 From: spbsoluble <1661003+spbsoluble@users.noreply.github.com> Date: Tue, 17 Nov 2026 10:23:58 -0800 Subject: [PATCH 01/12] fix(v2): don't block wildcard-SAN orders when the catalog can't name a Wildcard UCC product A DV/OV request with CN = apex and SAN = *.apex and no template ProductCode was rejected before ordering whenever the catalog didn't list exactly one active product with productTypeID 21/22. Catalogs on other CA backends (SSL.com) need not use those IDs, and there CERTInext accepts this shape with no X-Product-Code. Now: - One active Wildcard UCC product: its code is sent, as before. - None, several, or an unreadable catalog: a warning is logged and the order is placed with no X-Product-Code. An EMS-1173 from CERTInext then says to set ProductCode on the template. EV still fails before ordering. - Explicit ProductCode whose catalog entry has no documented SSL productTypeID (not listed, none, unfamiliar, or no catalog): UCC is decided from the request's SANs instead of rejecting extra SANs, and template save-time validation accepts the code instead of reporting a product mismatch. - Flat catalog rows keyed by productCode are available when they carry no "active" field, and a numeric productTypeID no longer fails the read. Also clears a CS8602 on the SSL.com organization check (the variant is "ov" or "ev" there). --- CERTInext.Tests/CERTInextCAPluginV2Tests.cs | 29 ++++ CERTInext.Tests/CERTInextClientV2Tests.cs | 25 +++- .../V2ProductCodeResolutionTests.cs | 123 ++++++++++++++-- CERTInext/CERTInextCAPlugin.cs | 134 ++++++++++++------ CERTInext/Client/CERTInextClient.cs | 17 ++- CHANGELOG.md | 4 +- docsource/configuration.md | 4 +- 7 files changed, 280 insertions(+), 56 deletions(-) diff --git a/CERTInext.Tests/CERTInextCAPluginV2Tests.cs b/CERTInext.Tests/CERTInextCAPluginV2Tests.cs index 8c4c49a..9bc6205 100644 --- a/CERTInext.Tests/CERTInextCAPluginV2Tests.cs +++ b/CERTInext.Tests/CERTInextCAPluginV2Tests.cs @@ -1725,6 +1725,35 @@ await act.Should().ThrowAsync() .WithMessage("*does not correspond to the selected product*"); } + // A catalog on another CA backend (SSL.com) whose entry has no documented SSL productTypeID: + // the code exists, so it is accepted as given rather than rejected as a mismatch. + [Theory] + [InlineData(@"[{""productCode"":""1015"",""productName"":""SSL.com DV Wildcard UCC""}]")] + [InlineData(@"[{""productCode"":""1015"",""productName"":""SSL.com DV Wildcard UCC"",""productTypeID"":""101""}]")] + public async Task ValidateProductInfo_V2_Passes_WhenProductCodeExistsWithUndocumentedProductTypeId(string catalogBody) + { + using var server = WireMockServer.Start(); + StubV2TokenAndAuthMe(server); + server + .Given(Request.Create().WithPath("/api/certinext/v2/catalog/products").UsingGet()) + .RespondWith(Response.Create() + .WithStatusCode(200) + .WithHeader("Content-Type", "application/json") + .WithBody(catalogBody)); + + var plugin = BuildV2Plugin(NewMock().Object); + var connInfo = BuildV2ConnectionInfo(server.Urls[0]); + var productInfo = new EnrollmentProductInfo + { + ProductID = Constants.Products.DvSslWildcardUcc, + ProductParameters = new Dictionary { ["ProductCode"] = "1015" } + }; + + Func act = () => plugin.ValidateProductInfo(productInfo, connInfo); + + await act.Should().NotThrowAsync(); + } + // --------------------------------------------------------------------------- // No explicit ProductCode on a V2 template. X-Product-Code is the spec's optional override // (CERTInext resolves the product from the variant / wildcard shape / additionalDomains), diff --git a/CERTInext.Tests/CERTInextClientV2Tests.cs b/CERTInext.Tests/CERTInextClientV2Tests.cs index 01d9e3c..2d59c60 100644 --- a/CERTInext.Tests/CERTInextClientV2Tests.cs +++ b/CERTInext.Tests/CERTInextClientV2Tests.cs @@ -1613,7 +1613,30 @@ public async Task GetProductDetailsV2Async_FlatProductCodeRow_UccProductTypeId_P List products = await client.GetProductDetailsV2Async(); products.Should().ContainSingle(p => p.ProductCode == "851" && p.ProductTypeId == "20", - "UCC product's productTypeID must survive the flat productCode row shape (direct DTO deserialize)"); + "UCC product's productTypeID must survive the flat productCode row shape"); + } + + [Fact] + public async Task GetProductDetailsV2Async_FlatProductCodeRow_NoActiveField_NumericTypeId_IsActiveWithStringTypeId() + { + StubV2Token(); + _server + .Given(Request.Create().WithPath("/api/certinext/v2/catalog/products").UsingGet()) + .RespondWith(Response.Create() + .WithStatusCode(200) + .WithHeader("Content-Type", "application/json") + .WithBody(@"[ + {""productCode"":""845"",""productName"":""DV SSL Certificate Wildcard UCC"",""productTypeID"":21}, + {""productCode"":""842"",""productName"":""DV SSL Certificate"",""productTypeID"":""13"",""active"":false} +]")); + + using var client = BuildV2Client(); + List products = await client.GetProductDetailsV2Async(); + + products.Should().ContainSingle(p => p.ProductCode == "845" && p.ProductTypeId == "21" && p.Active, + "a row without an \"active\" field is available, and a numeric productTypeID reads as its string form"); + products.Should().ContainSingle(p => p.ProductCode == "842" && !p.Active, + "an explicit \"active\": false is kept"); } [Fact] diff --git a/CERTInext.Tests/V2ProductCodeResolutionTests.cs b/CERTInext.Tests/V2ProductCodeResolutionTests.cs index c5fa3ed..992ca61 100644 --- a/CERTInext.Tests/V2ProductCodeResolutionTests.cs +++ b/CERTInext.Tests/V2ProductCodeResolutionTests.cs @@ -276,26 +276,38 @@ public static IEnumerable UnresolvableCatalogs() => new[] new ProductDetail { ProductCode = "845", ProductTypeId = "21", Active = true }, new ProductDetail { ProductCode = "1021", ProductTypeId = "21", Active = true }, } }, + // A catalog on another CA backend (SSL.com) whose entries carry no documented productTypeID. + new object[] { "no type ids", new List + { + new ProductDetail { ProductCode = "1011", Active = true }, + new ProductDetail { ProductCode = "1012", ProductTypeId = "101", Active = true }, + } }, }; + // The catalog names no single Wildcard UCC product: the order goes out unpinned and CERTInext + // picks the product, as a customer's direct API call of this shape does (and issues). [Theory] [MemberData(nameof(UnresolvableCatalogs))] - public async Task NoExplicitProductCode_WildcardSanOnApexCn_NoSingleWildcardUccProduct_FailsWithoutPlacing( + public async Task NoExplicitProductCode_WildcardSanOnApexCn_NoSingleWildcardUccProduct_PlacesUnpinned( string label, List catalog) { + using var capture = new PluginLogCapture(); var (mock, cap) = NewSslMock(); mock.Setup(c => c.GetProductDetailsV2Async(It.IsAny())).ReturnsAsync(catalog); var plugin = new CERTInextCAPlugin(mock.Object, Config()); var result = await EnrollAsync(plugin, ProductInfo(Constants.Products.DvSsl), "example.com", "*.example.com"); - result.Status.Should().Be((int)EndEntityStatus.FAILED, label); - result.StatusMessage.Should().Contain("Wildcard UCC").And.Contain("ProductCode"); - cap.Placed.Should().BeFalse(); + result.CARequestID.Should().Be(OrderId, label); + cap.Placed.Should().BeTrue(label); + cap.ProductCode.Should().BeNull(label); + cap.Request.Certificate.Domain.Should().Be("example.com"); + cap.Request.Certificate.AdditionalDomains.Should().Equal("*.example.com"); + capture.Lines(LogLevel.Warning, "Sending no X-Product-Code").Should().ContainSingle(label); } [Fact] - public async Task NoExplicitProductCode_WildcardSanOnApexCn_CatalogUnavailable_FailsWithoutPlacing() + public async Task NoExplicitProductCode_WildcardSanOnApexCn_CatalogUnavailable_PlacesUnpinned() { var (mock, cap) = NewSslMock(); mock.Setup(c => c.GetProductDetailsV2Async(It.IsAny())) @@ -304,9 +316,102 @@ public async Task NoExplicitProductCode_WildcardSanOnApexCn_CatalogUnavailable_F var result = await EnrollAsync(plugin, ProductInfo(Constants.Products.DvSsl), "example.com", "*.example.com"); - result.Status.Should().Be((int)EndEntityStatus.FAILED); - result.StatusMessage.Should().Contain("catalog could not be read"); - cap.Placed.Should().BeFalse(); + result.CARequestID.Should().Be(OrderId); + cap.ProductCode.Should().BeNull(); + cap.Request.Certificate.AdditionalDomains.Should().Equal("*.example.com"); + } + + [Fact] + public async Task NoExplicitProductCode_WildcardSanOnApexCn_Unpinned_Ems1173_SaysToSetProductCode() + { + var mock = new Mock(MockBehavior.Strict); + mock.Setup(c => c.GetProductDetailsV2Async(It.IsAny())) + .ReturnsAsync(new List()); + mock.Setup(c => c.PlaceOrderV2Async( + It.IsAny(), It.IsAny(), + It.IsAny(), It.IsAny())) + .ThrowsAsync(new Exception( + "CERTInext V2 API error during 'V2 place order'. HTTP 422. Unprocessable Entity: " + + "[EMS-1173] Invalid Additional Domain Names (*.example.com)")); + var plugin = new CERTInextCAPlugin(mock.Object, Config()); + + Func act = () => EnrollAsync(plugin, ProductInfo(Constants.Products.DvSsl), "example.com", "*.example.com"); + + (await act.Should().ThrowAsync()) + .Which.Message.Should().Contain("EMS-1173").And.Contain("Set ProductCode on the template"); + } + + [Fact] + public async Task NoExplicitProductCode_PlainUcc_Ems1173_IsNotReworded() + { + var mock = new Mock(MockBehavior.Strict); + const string caError = "CERTInext V2 API error during 'V2 place order'. HTTP 422. Unprocessable Entity: " + + "[EMS-1173] Invalid Additional Domain Names (bad..example.com)"; + mock.Setup(c => c.PlaceOrderV2Async( + It.IsAny(), It.IsAny(), + It.IsAny(), It.IsAny())) + .ThrowsAsync(new Exception(caError)); + var plugin = new CERTInextCAPlugin(mock.Object, Config()); + + Func act = () => EnrollAsync(plugin, ProductInfo(Constants.Products.DvSsl), "example.com", "other.example.com"); + + (await act.Should().ThrowAsync()).Which.Message.Should().Be(caError); + } + + // Explicit ProductCode whose catalog entry doesn't carry a documented SSL productTypeID (code not + // listed, no type, an unfamiliar type, or no catalog): the request decides, so the wildcard SAN + // goes out in additionalDomains instead of being rejected as an extra SAN. + public static IEnumerable UnidentifiedExplicitCodeCatalogs() => new[] + { + new object[] { "not listed", new List { new ProductDetail { ProductCode = "842", ProductTypeId = "13", Active = true } } }, + new object[] { "no type id", new List { new ProductDetail { ProductCode = "1015", Active = true } } }, + new object[] { "unfamiliar type id", new List { new ProductDetail { ProductCode = "1015", ProductTypeId = "101", Active = true } } }, + }; + + [Theory] + [MemberData(nameof(UnidentifiedExplicitCodeCatalogs))] + public async Task ExplicitProductCode_UnidentifiedByCatalog_WildcardSanOnApexCn_DecidesFromTheRequest( + string label, List catalog) + { + var (mock, cap) = NewSslMock(); + mock.Setup(c => c.GetProductDetailsV2Async(It.IsAny())).ReturnsAsync(catalog); + var plugin = new CERTInextCAPlugin(mock.Object, Config()); + + var result = await EnrollAsync(plugin, ProductInfo(Constants.Products.DvSsl, productCode: "1015"), + "example.com", "*.example.com"); + + result.CARequestID.Should().Be(OrderId, label); + cap.ProductCode.Should().Be("1015", label); + cap.Request.Certificate.AdditionalDomains.Should().Equal("*.example.com"); + } + + [Fact] + public async Task ExplicitProductCode_CatalogUnavailable_ExtraSan_DecidesFromTheRequest() + { + var (mock, cap) = NewSslMock(); + mock.Setup(c => c.GetProductDetailsV2Async(It.IsAny())) + .ThrowsAsync(new Exception("catalog down")); + var plugin = new CERTInextCAPlugin(mock.Object, Config()); + + var result = await EnrollAsync(plugin, ProductInfo(Constants.Products.DvSsl, productCode: "844"), + "example.com", "extra.example.com"); + + result.CARequestID.Should().Be(OrderId); + cap.Request.Certificate.AdditionalDomains.Should().Equal("extra.example.com"); + } + + [Fact] + public async Task ExplicitProductCode_UnidentifiedByCatalog_SingleDomain_SendsNoAdditionalDomains() + { + var (mock, cap) = NewSslMock(); + mock.Setup(c => c.GetProductDetailsV2Async(It.IsAny())) + .ReturnsAsync(new List { new ProductDetail { ProductCode = "1011", Active = true } }); + var plugin = new CERTInextCAPlugin(mock.Object, Config()); + + await EnrollAsync(plugin, ProductInfo(Constants.Products.DvSsl, productCode: "1011"), "example.com"); + + cap.ProductCode.Should().Be("1011"); + (cap.Request.Certificate.AdditionalDomains ?? new List()).Should().BeEmpty(); } [Fact] @@ -347,7 +452,7 @@ public async Task OrderCreated_WithoutResolvedProductCodeInResponse_LogsNotRepor await EnrollAsync(plugin, ProductInfo(Constants.Products.DvSsl, productCode: "842"), "example.com"); // (the explicit code path reads the catalog; it is not stubbed here, so the plugin logs a - // warning and treats the order as single-domain) + // warning and decides UCC from the request's SANs) var lines = capture.Lines(LogLevel.Information, "V2 order placed"); lines.Should().ContainSingle(); lines[0].Should().Contain("ResolvedProductCode=(not reported)").And.Contain("XProductCodeSent=842"); diff --git a/CERTInext/CERTInextCAPlugin.cs b/CERTInext/CERTInextCAPlugin.cs index 0b69db6..1855312 100644 --- a/CERTInext/CERTInextCAPlugin.cs +++ b/CERTInext/CERTInextCAPlugin.cs @@ -971,8 +971,19 @@ public async Task ValidateProductInfo(EnrollmentProductInfo productInfo, Diction $"Available codes: {available}"); } - if (Constants.Products.ProductTypeIdsV2.TryGetValue(params_.ProductId ?? string.Empty, out string expectedTypeId) - && !string.Equals(matchedProduct.ProductTypeId, expectedTypeId, StringComparison.OrdinalIgnoreCase)) + // Compared only when the catalog entry carries one of the documented SSL productTypeIDs: + // catalogs on other CA backends (SSL.com) need not, and the code is then taken as given. + string matchedTypeId = matchedProduct.ProductTypeId?.Trim(); + if (string.IsNullOrEmpty(matchedTypeId) || !Constants.Products.ProductTypeIdsV2.ContainsValue(matchedTypeId)) + { + _logger.LogInformation( + "Product/profile validation: ProductCode '{ProfileId}' is in the CERTInext V2 catalog " + + "with productTypeID '{TypeId}', which isn't a documented SSL product type; not checking " + + "it against the selected ProductID '{ProductID}'.", + profileId, matchedTypeId ?? "(none)", params_.ProductId); + } + else if (Constants.Products.ProductTypeIdsV2.TryGetValue(params_.ProductId ?? string.Empty, out string expectedTypeId) + && !string.Equals(matchedTypeId, expectedTypeId, StringComparison.OrdinalIgnoreCase)) { _logger.LogWarning( "Product/profile validation failed — configured ProductCode '{ProfileId}' exists in " + @@ -1793,18 +1804,18 @@ internal static List FindExtraDnsSans( } /// - /// The account's Wildcard UCC product code for an SSL , read - /// from the live V2 catalog (the single active product whose productTypeID is - /// 's entry for the variant). - /// Returns (code, null) on success, else (null, reason): the variant has no - /// wildcard product (EV), the catalog could not be read, or it lists zero or several matches. - /// Each reason tells the user to set ProductCode on the template, which skips this lookup. + /// The account's Wildcard UCC product code for an SSL + /// that has one (DV/OV; the caller rejects EV first), read from the live V2 catalog: the single + /// active product whose productTypeID is 's + /// entry for the variant. Returns (code, null) on success, else (null, reason) + /// when the catalog could not be read or lists zero or several matches. The caller then sends + /// no X-Product-Code and leaves the product to CERTInext: catalogs on other CA backends + /// (SSL.com) need not carry these productTypeIDs, and there CERTInext accepts this shape + /// unpinned (reported by a customer; not reproducible on our emSign sandbox). /// - private async Task<(string ProductCode, string Error)> ResolveWildcardUccProductCodeAsync(string productVariant) + private async Task<(string ProductCode, string Unresolved)> ResolveWildcardUccProductCodeAsync(string productVariant) { - const string setCode = "Set ProductCode on the template to the account's Wildcard UCC product code."; - if (!Constants.ApiV2.WildcardUccProductTypeIdByVariant.TryGetValue(productVariant ?? string.Empty, out string typeId)) - return (null, $"Product variant '{productVariant}' has no wildcard product."); + string typeId = Constants.ApiV2.WildcardUccProductTypeIdByVariant[productVariant]; List catalog; try @@ -1814,7 +1825,7 @@ internal static List FindExtraDnsSans( catch (Exception ex) { _logger.LogWarning(ex, "EnrollV2Async: could not read the V2 product catalog to resolve a Wildcard UCC product."); - return (null, $"The product catalog could not be read to find the Wildcard UCC product. {setCode}"); + return (null, "The product catalog could not be read to find the Wildcard UCC product."); } var matches = (catalog ?? new List()) @@ -1832,8 +1843,8 @@ internal static List FindExtraDnsSans( } return (null, matches.Count == 0 - ? $"The account's catalog has no active Wildcard UCC product (productTypeID {typeId}). {setCode}" - : $"The account's catalog has several active Wildcard UCC products ({string.Join(", ", matches)}). {setCode}"); + ? $"The account's catalog has no active Wildcard UCC product (productTypeID {typeId})." + : $"The account's catalog has several active Wildcard UCC products ({string.Join(", ", matches)})."); } /// @@ -2316,11 +2327,12 @@ private async Task EnrollV2CoreAsync( // // UCC / wildcard detection decides whether extra DNS SANs are carried in // additionalDomains (UCC) or rejected by the single-domain guard below: - // - Explicit override: the live catalog entry for the code is looked up and its - // productTypeID decides (UCC / non-UCC wildcard). A catalog lookup failure must not - // block enrollment — it falls back to non-UCC (single-domain), the strictly-safer - // failure mode: the guard below still runs and rejects a surplus-SAN CSR rather than - // silently accepting it. + // - Explicit override: the live catalog entry for the code is looked up and, when its + // productTypeID is one of the documented SSL types (13-22), that type decides (UCC / + // non-UCC wildcard). When it doesn't (catalog unreadable, code not listed, no or an + // unfamiliar productTypeID, as on catalogs of other CA backends such as SSL.com), the + // request shape decides, as with no override: extra DNS SANs make it UCC. The template + // author chose the code, and CERTInext rejects a code that can't carry those names. // - No override: no catalog call at all. The wildcard shape is the domain itself // (starts "*."), exactly what the wrapper keys on. UCC is the template's product // type (ProductId -> productTypeID, as before) OR the request carrying DNS SANs @@ -2328,8 +2340,10 @@ private async Task EnrollV2CoreAsync( // "extra"), which is what makes the wrapper pick a UCC product — so those extras go // out in additionalDomains instead of failing the single-domain guard. // One exception reads the catalog: a wildcard SAN on a non-wildcard domain (CN = - // apex, SAN = *.apex) needs a Wildcard UCC product the wrapper cannot infer, so its - // code is resolved and sent (ResolveWildcardUccProductCodeAsync). + // apex, SAN = *.apex) needs a Wildcard UCC product the wrapper cannot infer on our + // emSign sandbox, so the account's one is resolved and sent + // (ResolveWildcardUccProductCodeAsync). If the catalog doesn't name exactly one, no + // code is sent and CERTInext decides. // // Private PKI: ProductCode is likewise optional (the wrapper resolves it from // `variant`); the catalog is never fetched because its only use on this path — SSL UCC @@ -2337,6 +2351,9 @@ private async Task EnrollV2CoreAsync( string productCode = ep.HasExplicitProductCode ? ep.ProductCode : null; bool isUccProduct = false; bool isWildcardProduct = false; + // Set when a wildcard SAN on a non-wildcard domain goes out with no X-Product-Code, so an + // EMS-1173 from the create can say how to pin the product. + bool wildcardSanUnpinned = false; if (!isPrivatePki && ep.HasExplicitProductCode) { List catalog = null; @@ -2348,17 +2365,28 @@ private async Task EnrollV2CoreAsync( { _logger.LogWarning(catalogEx, "EnrollV2Async: could not fetch the live V2 product catalog to detect UCC/wildcard for the " + - "explicit ProductCode; treating the order as single-domain. ProductId={ProductId}", ep.ProductId); + "explicit ProductCode; deciding from the request's SANs. ProductId={ProductId}", ep.ProductId); } var matchedProduct = catalog?.FirstOrDefault(p => string.Equals(p.ProductCode, ep.ProductCode, StringComparison.OrdinalIgnoreCase)); - isUccProduct = matchedProduct != null - && !string.IsNullOrWhiteSpace(matchedProduct.ProductTypeId) - && Constants.ApiV2.UccProductTypeIds.Contains(matchedProduct.ProductTypeId); - isWildcardProduct = matchedProduct != null - && !string.IsNullOrWhiteSpace(matchedProduct.ProductTypeId) - && Constants.ApiV2.WildcardProductTypeIds.Contains(matchedProduct.ProductTypeId); + string matchedTypeId = matchedProduct?.ProductTypeId?.Trim(); + if (!string.IsNullOrEmpty(matchedTypeId) + && Constants.Products.ProductTypeIdsV2.ContainsValue(matchedTypeId)) + { + isUccProduct = Constants.ApiV2.UccProductTypeIds.Contains(matchedTypeId); + isWildcardProduct = Constants.ApiV2.WildcardProductTypeIds.Contains(matchedTypeId); + } + else + { + isWildcardProduct = domain.StartsWith("*.", StringComparison.Ordinal); + isUccProduct = FindExtraDnsSans(csr, san, domain, isWildcardProduct).Count > 0; + _logger.LogInformation( + "EnrollV2Async: the catalog doesn't identify explicit ProductCode {ProductCode} as a known SSL " + + "product type (productTypeID={TypeId}); deciding from the request instead. Wildcard={Wildcard}, " + + "Ucc={Ucc}", ep.ProductCode, matchedProduct == null ? "(not listed)" : matchedTypeId ?? "(none)", + isWildcardProduct, isUccProduct); + } } else if (!isPrivatePki) { @@ -2373,19 +2401,20 @@ private async Task EnrollV2CoreAsync( // "wildcard" on certificate.domain alone, so it resolves a plain UCC product and // rejects the wildcard additional domain (EMS-1173). Sending the wildcard as the // domain instead is rejected too, because the domain must match the CSR CN - // (EMS-1056). Both confirmed live (V2WildcardSanShapeTests). The order needs a - // Wildcard UCC product, which only an explicit X-Product-Code selects, so resolve - // the account's one from the catalog. Fail before placing an order when that can't - // be done unambiguously. + // (EMS-1056). Both confirmed live on our emSign sandbox (V2WildcardSanShapeTests). The + // order there needs a Wildcard UCC product, which only an explicit X-Product-Code + // selects, so resolve the account's one from the catalog. When the catalog doesn't + // name exactly one (seen on a customer's account, likely SSL.com-backed, whose direct + // unpinned orders of this shape issue), send no code and let CERTInext decide. EV has + // no wildcard product at all, so that still fails before placing an order. if (!isWildcardProduct && extraDnsSans.Any(s => s.StartsWith("*.", StringComparison.Ordinal))) { - string wildcardUccError; - (productCode, wildcardUccError) = await ResolveWildcardUccProductCodeAsync(sslProductVariant); - if (wildcardUccError != null) + if (!Constants.ApiV2.WildcardUccProductTypeIdByVariant.ContainsKey(sslProductVariant ?? string.Empty)) { _logger.LogError( "EnrollV2Async rejected an order with a wildcard SAN on a non-wildcard domain '{Domain}': " + - "{Reason}", LogSanitizer.Strip(domain), wildcardUccError); + "product variant '{Variant}' has no wildcard product.", + LogSanitizer.Strip(domain), sslProductVariant); _logger.MethodExit(LogLevel.Debug); return new EnrollmentResult { @@ -2394,9 +2423,22 @@ private async Task EnrollV2CoreAsync( Status = (int)EndEntityStatus.FAILED, StatusMessage = $"V2 enrollment rejected: the request carries a wildcard SAN but its " + $"primary domain ('{domain}', the CSR CN) is not a wildcard, which needs " + - $"a Wildcard UCC product. {wildcardUccError} No order was placed." + $"a Wildcard UCC product. Product variant '{sslProductVariant}' has no " + + "wildcard product. No order was placed." }; } + + string unresolved; + (productCode, unresolved) = await ResolveWildcardUccProductCodeAsync(sslProductVariant); + if (productCode == null) + { + wildcardSanUnpinned = true; + _logger.LogWarning( + "EnrollV2Async: wildcard SAN on non-wildcard domain '{Domain}' with no Wildcard UCC product " + + "code to send: {Reason} Sending no X-Product-Code; CERTInext resolves the product. If it " + + "rejects the wildcard (EMS-1173), set ProductCode on the template.", + LogSanitizer.Strip(domain), unresolved); + } } _logger.LogInformation( @@ -2636,7 +2678,7 @@ private async Task EnrollV2CoreAsync( if (isOvOrEv && !string.IsNullOrWhiteSpace(_config.OrganizationNumber)) { await EnsureSslComOrganizationValidationAsync( - _config.OrganizationNumber, sslProductVariant.ToUpperInvariant()); + _config.OrganizationNumber, sslProductVariant!.ToUpperInvariant()); // isOvOrEv: "ov" or "ev" } // V2 SSL/TLS reissue: POST /ssl-certificates/{prior}/reissue creates a derived order that @@ -2711,7 +2753,19 @@ await EnsureSslComOrganizationValidationAsync( Remarks = remarks, GroupNumber = groupNumber }; - createResp = await _client.PlaceOrderV2Async(ep.ProductFamilySlug, productCode, orderReq); + try + { + createResp = await _client.PlaceOrderV2Async(ep.ProductFamilySlug, productCode, orderReq); + } + catch (Exception createEx) when (wildcardSanUnpinned + && createEx.Message?.IndexOf("EMS-1173", StringComparison.OrdinalIgnoreCase) >= 0) + { + // CERTInext picked a product that can't carry the wildcard additional domain. + throw new Exception( + $"{createEx.Message} The request carries a wildcard SAN on a non-wildcard primary domain " + + "and the catalog named no single Wildcard UCC product to send. Set ProductCode on the " + + "template to the account's Wildcard UCC product code.", createEx); + } } string orderId = createResp.OrderId; diff --git a/CERTInext/Client/CERTInextClient.cs b/CERTInext/Client/CERTInextClient.cs index bf4d027..2e7ba8d 100644 --- a/CERTInext/Client/CERTInextClient.cs +++ b/CERTInext/Client/CERTInextClient.cs @@ -2307,10 +2307,21 @@ private List ParseProductDetailsV2Response(string content) }); } } - else if (element.TryGetProperty("productCode", out _)) + else if (element.TryGetProperty("productCode", out var fpc)) { - // Flat row already shaped like ProductDetail. - result.Add(JsonSerializer.Deserialize(element.GetRawText(), GetJsonOptions())); + // Flat row shaped like ProductDetail. Read field by field like the branches around it: + // deserializing would leave Active false when the row has no "active" field, and throw on + // a numeric productTypeID. + result.Add(new ProductDetail + { + ProductCode = fpc.ValueKind == JsonValueKind.String ? fpc.GetString() : fpc.ToString(), + ProductName = element.TryGetProperty("productName", out var fpn) && fpn.ValueKind == JsonValueKind.String ? fpn.GetString() : null, + ProductType = element.TryGetProperty("productType", out var fptype) && fptype.ValueKind == JsonValueKind.String ? fptype.GetString() : null, + ProductTypeId = element.TryGetProperty("productTypeID", out var fpt) + ? (fpt.ValueKind == JsonValueKind.String ? fpt.GetString() : fpt.ToString()) + : null, + Active = !element.TryGetProperty("active", out var fa) || fa.ValueKind != JsonValueKind.False + }); } else if (element.TryGetProperty("productId", out var pid)) { diff --git a/CHANGELOG.md b/CHANGELOG.md index 351455e..f68e418 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,7 +21,9 @@ - feat(config): V2 orders honor `GroupNumber`, `OrganizationNumber`, `TechnicalContact*`, `EmailNotifications`, and the subscription renewal settings. ## Bug Fixes -- fix(v2): A DV or OV request whose CN is a plain name and whose SANs carry a wildcard (CN `example.com`, SAN `*.example.com`) no longer fails with `EMS-1173 Invalid Additional Domain Names`. CERTInext treats an order as wildcard only when its domain is a wildcard, and it rejects a domain that differs from the CN (`EMS-1056`). With no `ProductCode` on the template, the plugin now looks up the account's single active Wildcard UCC product in the catalog and sends its code. If there isn't exactly one, or the catalog can't be read, enrollment fails before placing an order and asks you to set `ProductCode`. +- fix(v2): A DV or OV request whose CN is a plain name and whose SANs carry a wildcard (CN `example.com`, SAN `*.example.com`) no longer fails with `EMS-1173 Invalid Additional Domain Names`. CERTInext treats an order as wildcard only when its domain is a wildcard, and it rejects a domain that differs from the CN (`EMS-1056`). With no `ProductCode` on the template, the plugin now looks up the account's single active Wildcard UCC product in the catalog and sends its code. If there isn't exactly one, or the catalog can't be read, the order is placed without `X-Product-Code` and CERTInext picks the product, as accounts on other CA backends (such as SSL.com) need; an `EMS-1173` from CERTInext then asks you to set `ProductCode`. EV requests in this shape are still rejected before ordering. +- fix(v2): With an explicit `ProductCode` whose catalog entry has no documented SSL `productTypeID` (not listed, no type, an unfamiliar type, or an unreadable catalog), extra SANs (including a wildcard SAN) are sent as `additionalDomains` instead of being rejected as a single-domain order. Template save-time validation likewise accepts such a code instead of rejecting it as a product mismatch. +- fix(v2): Flat catalog rows with a `productCode` key are read as available when they have no `active` field, and a numeric `productTypeID` no longer fails the catalog read. - fix(v2): A 422 `EMS-1165` from Download Certificate on an order CERTInext reports as `issued` is treated as "certificate not generated yet": the enrollment pickup keeps polling and returns pending, logging per attempt at Debug and one Information summary instead of a warning each time. `GetSingleRecord` and Synchronize log it quietly too (the sync summary gains `IssuedNotGeneratedYet`), and the log lines include CERTInext's `orderState` and `certificateState`. Other download errors still warn. - fix(v2): `EmailNotifications=0` (silent) is sent as `consent-only` on V2 order create, the quietest value in the spec's `consent-only | all` enum; the old `"0"` isn't a member of it. - fix(v2): Order create no longer sends `agreement.signerIp`, which isn't in the V2 spec's `Agreement` schema; the `SignerIp` settings now apply to V1 only. diff --git a/docsource/configuration.md b/docsource/configuration.md index 548a12b..531d2a5 100644 --- a/docsource/configuration.md +++ b/docsource/configuration.md @@ -578,8 +578,8 @@ When `UseV2Api` is `true`, the plugin does not choose a numeric product code. Th 1. **No `ProductCode` on the template (the default)** — no `X-Product-Code` header is sent, with one exception, described below. The connector's `DefaultProductCode` is not used. Save-time validation does no catalog check. The plugin decides whether the order is wildcard or multi-domain from the request itself: - **Wildcard:** the primary domain starts with `*.`. - **Multi-domain:** the selected product is a UCC product, or the CSR or gateway SAN list carries DNS names beyond the primary domain (its `www.` variant, and a wildcard's bare apex, don't count). Those names are sent as `additionalDomains`, which makes CERTInext choose a UCC product. - - **Wildcard in the SANs only (the exception):** the CN is a plain name, such as `example.com`, and a SAN is a wildcard, such as `*.example.com`. CERTInext can't resolve this request itself. It treats an order as wildcard only when `certificate.domain` starts with `*.`, so it picks a plain UCC product and rejects the wildcard with `EMS-1173 Invalid Additional Domain Names`. Sending the wildcard as the domain doesn't work either: CERTInext requires the domain to match the CSR CN (`EMS-1056`). For this case, the plugin reads the account's catalog once. If the catalog has exactly one active Wildcard UCC product for the variant (`productTypeID` `21` for DV, `22` for OV), the plugin sends that product's code as `X-Product-Code`. It keeps the CN as the domain and sends the wildcard in `additionalDomains`. If no single product matches, or the catalog can't be read, enrollment fails before any order is placed, and the message asks you to set `ProductCode` on the template. Setting it also skips the lookup. EV has no wildcard product, so EV requests in this shape are rejected. -2. **Explicit `ProductCode` (or the deprecated `ProfileId` alias)** — the override. It is sent as-is in the `X-Product-Code` header, after template save-time validation confirms it exists in the live V2 catalog and matches the selected product. Use it when your account holds several matching products (for example different CA profiles for the same variant) and you want to force one. With an override, the plugin reads the catalog once per enrollment to recognize UCC and wildcard products, and rejects extra SANs on a single-domain product. + - **Wildcard in the SANs only (the exception):** the CN is a plain name, such as `example.com`, and a SAN is a wildcard, such as `*.example.com`. On some accounts CERTInext can't resolve this request itself. It treats an order as wildcard only when `certificate.domain` starts with `*.`, so it picks a plain UCC product and rejects the wildcard with `EMS-1173 Invalid Additional Domain Names`. Sending the wildcard as the domain doesn't work either: CERTInext requires the domain to match the CSR CN (`EMS-1056`). For this case, the plugin reads the account's catalog once. If the catalog has exactly one active Wildcard UCC product for the variant (`productTypeID` `21` for DV, `22` for OV), the plugin sends that product's code as `X-Product-Code`. It keeps the CN as the domain and sends the wildcard in `additionalDomains`. If no single product matches, or the catalog can't be read, the plugin logs a warning and places the order without `X-Product-Code`, leaving the product to CERTInext. Catalogs on other CA backends (such as SSL.com) need not use these `productTypeID` values. If CERTInext then rejects the wildcard (`EMS-1173`), the error asks you to set `ProductCode` on the template, which also skips the lookup. EV has no wildcard product, so EV requests in this shape are rejected before any order is placed. +2. **Explicit `ProductCode` (or the deprecated `ProfileId` alias)** — the override. It is sent as-is in the `X-Product-Code` header, after template save-time validation confirms it exists in the live V2 catalog and matches the selected product. The match is checked only when the catalog entry has a documented SSL `productTypeID`; otherwise the code is accepted as given. Use it when your account holds several matching products (for example different CA profiles for the same variant) and you want to force one. With an override, the plugin reads the catalog once per enrollment to recognize UCC and wildcard products. When the catalog entry has a documented SSL `productTypeID` (`13`-`22`), a single-domain product rejects extra SANs. When it doesn't (the code isn't listed, the entry has no or an unfamiliar `productTypeID`, or the catalog can't be read), the plugin decides from the request the same way as without an override: extra DNS names make it multi-domain and go out in `additionalDomains`, and CERTInext rejects the code if it can't carry them. This differs from V1, where `DefaultProductCode` only affects renewals (see [DefaultProductCode](#defaultproductcode)). From da31c49c26d331d5a6810e4fe7f6018f8752968a Mon Sep 17 00:00:00 2001 From: spbsoluble <1661003+spbsoluble@users.noreply.github.com> Date: Tue, 17 Nov 2026 10:23:58 -0800 Subject: [PATCH 02/12] test(live): raw wildcard-SAN probe, Private PKI variant/leave-pending switches, V1 enroll logging - V2WildcardSanShapeTests.Probe_Raw_ApexCn_WildcardSan posts the create body directly (no X-Product-Code, CSR inline, CN = apex, SAN = *.apex), with and without additionalDomains. - PrivatePkiV2LiveTests routes plugin logs to the test output and takes CERTINEXT_PRIVATE_PKI_VARIANT and CERTINEXT_PRIVATE_PKI_LEAVE_PENDING. - DcvLifecycleTests.EnrollWithoutDcv_DoesNotInvokeDnsProvider routes plugin logs and prints the enroll result. --- .../DcvLifecycleTests.cs | 37 +++++--- .../INTEGRATION_TESTING.md | 2 +- .../PrivatePkiV2LiveTests.cs | 23 ++++- .../V2WildcardSanShapeTests.cs | 89 +++++++++++++++++++ docsource/development.md | 4 +- 5 files changed, 137 insertions(+), 18 deletions(-) diff --git a/CERTInext.IntegrationTests/DcvLifecycleTests.cs b/CERTInext.IntegrationTests/DcvLifecycleTests.cs index 5f2d57e..695c131 100644 --- a/CERTInext.IntegrationTests/DcvLifecycleTests.cs +++ b/CERTInext.IntegrationTests/DcvLifecycleTests.cs @@ -199,20 +199,33 @@ public async Task EnrollWithoutDcv_DoesNotInvokeDnsProvider() { IntegrationSkip.IfNotConfigured(_fixture); - // Use a plugin backed by the real client but DcvEnabled=false - var plugin = BuildPlugin(dcvEnabled: false); + // Route plugin/client logs to the test output (before the plugin is constructed), so the CA's + // answer to the V1 order is visible. + var restoreLogging = TestOutputLogging.RouteTo(_output); + EnrollmentResult result; + try + { + // Use a plugin backed by the real client but DcvEnabled=false + var plugin = BuildPlugin(dcvEnabled: false); - var result = await plugin.Enroll( - csr: GenerateCsrPem(IntegrationTestData.DcvTestDomain), - subject: $"CN={IntegrationTestData.DcvTestDomain}", - san: new Dictionary - { - ["dns"] = new[] { IntegrationTestData.DcvTestDomain } - }, - productInfo: IntegrationTestData.DvSslProductInfo(_fixture.Config.DefaultProductCode), - requestFormat: RequestFormat.PKCS10, - enrollmentType: EnrollmentType.New); + result = await plugin.Enroll( + csr: GenerateCsrPem(IntegrationTestData.DcvTestDomain), + subject: $"CN={IntegrationTestData.DcvTestDomain}", + san: new Dictionary + { + ["dns"] = new[] { IntegrationTestData.DcvTestDomain } + }, + productInfo: IntegrationTestData.DvSslProductInfo(_fixture.Config.DefaultProductCode), + requestFormat: RequestFormat.PKCS10, + enrollmentType: EnrollmentType.New); + } + finally + { + restoreLogging(); + } + _output.WriteLine($"RESULT: CARequestID={result?.CARequestID ?? "(none)"}, Status={result?.Status}, " + + $"Message={result?.StatusMessage}"); result.Should().NotBeNull(); } diff --git a/CERTInext.IntegrationTests/INTEGRATION_TESTING.md b/CERTInext.IntegrationTests/INTEGRATION_TESTING.md index 8bba2db..dd7a1d8 100644 --- a/CERTInext.IntegrationTests/INTEGRATION_TESTING.md +++ b/CERTInext.IntegrationTests/INTEGRATION_TESTING.md @@ -150,7 +150,7 @@ matching flag in your shell. These flags are deliberately **not** read from `~/. | `CERTINEXT_V2_LIFECYCLE_DV_UCC=1`, `_OV=1`, `_OV_UCC=1`, `_EV=1`, `_WILDCARD_DV=1`, `_RENEW_REISSUE=1` | The matching `V2FullLifecycleTests` method; the OV and OV UCC tests also need `CERTINEXT_ORG_NUMBER`, and the EV test needs its own pre-vetted `CERTINEXT_EV_ORG_NUMBER` | | `CERTINEXT_V2_LIFECYCLE_FRESH_DCV=1` | `V2FreshDomainDcvLifecycleTests` (also needs Cloudflare and `CERTINEXT_V2_FRESH_DCV_PARENT`, the parent domain that fresh subdomains are created under) | | `CERTINEXT_V2_INLINE_CSR=0` | Not a test gate: runs the V2 enrollment tests (`V2LifecycleTests`, `V2FullLifecycleTests`, `V2DcvLifecycleTests`, `V2FreshDomainDcvLifecycleTests`, `PrivatePkiV2LiveTests`) with the `V2InlineCsr` connector setting off (SSL/TLS two-call: create, then submit CSR). Unset runs the default single-call flow; run the suite once in each mode. Private PKI stays two-call either way | -| `CERTINEXT_PRIVATE_PKI_LIVE=1` | `PrivatePkiV2LiveTests.PrivatePki_V2_EnrollIntranetSsl_ThenRevoke_Live`; override the product code and CN with `CERTINEXT_PRIVATE_PKI_PRODUCT_CODE` and `CERTINEXT_PRIVATE_PKI_CN` | +| `CERTINEXT_PRIVATE_PKI_LIVE=1` | `PrivatePkiV2LiveTests.PrivatePki_V2_EnrollIntranetSsl_ThenRevoke_Live`; override the product code and CN with `CERTINEXT_PRIVATE_PKI_PRODUCT_CODE` and `CERTINEXT_PRIVATE_PKI_CN`, the variant with `CERTINEXT_PRIVATE_PKI_VARIANT`, and set `CERTINEXT_PRIVATE_PKI_LEAVE_PENDING=1` (process env) to leave an unissued order pending for manual approval | | `CERTINEXT_V2_OPS_TESTS=1` | `V2OrderWindowSweepTests` — see below | Further variables select existing orders for specific tests: `CERTINEXT_PENDING_ORDER_ID` diff --git a/CERTInext.IntegrationTests/PrivatePkiV2LiveTests.cs b/CERTInext.IntegrationTests/PrivatePkiV2LiveTests.cs index ad8aa96..34ffd10 100644 --- a/CERTInext.IntegrationTests/PrivatePkiV2LiveTests.cs +++ b/CERTInext.IntegrationTests/PrivatePkiV2LiveTests.cs @@ -52,13 +52,14 @@ namespace Keyfactor.Extensions.CAPlugin.CERTInext.IntegrationTests /// from ~/.env_certinext_v2 by , same as . /// [Collection(PrivatePkiV2LiveCollection.Name)] - public class PrivatePkiV2LiveTests : IClassFixture + public class PrivatePkiV2LiveTests : IClassFixture, IDisposable { private const string OptInFlag = "CERTINEXT_PRIVATE_PKI_LIVE"; private const string IpSan = "10.0.0.50"; private readonly IntegrationTestFixture _fixture; private readonly ITestOutputHelper _output; + private readonly Action _restoreLogging; private readonly bool _optedIn; private readonly string _v2ApiUrl; @@ -66,12 +67,15 @@ public class PrivatePkiV2LiveTests : IClassFixture private readonly string _v2ClientSecret; private readonly string _productCode; private readonly string _cnOverride; + private readonly string _variant; + private readonly bool _leavePending; private readonly bool _v2CredsPresent; public PrivatePkiV2LiveTests(IntegrationTestFixture fixture, ITestOutputHelper output) { _fixture = fixture; _output = output; + _restoreLogging = TestOutputLogging.RouteTo(output); // Read the opt-in flag from the real process environment BEFORE promoting the V2 env // file, so leaving the flag in ~/.env_certinext_v2 cannot arm this order-placing test. @@ -83,12 +87,17 @@ public PrivatePkiV2LiveTests(IntegrationTestFixture fixture, ITestOutputHelper o _v2ClientSecret = V2EnvHelper.GetEnv(env, "CERTINEXT_CLIENT_SECRET"); _productCode = V2EnvHelper.GetEnv(env, "CERTINEXT_PRIVATE_PKI_PRODUCT_CODE", "149"); _cnOverride = V2EnvHelper.GetEnv(env, "CERTINEXT_PRIVATE_PKI_CN"); + _variant = V2EnvHelper.GetEnv(env, "CERTINEXT_PRIVATE_PKI_VARIANT", Constants.ApiV2.PrivatePkiVariantIntranetSsl); + // Read from the process environment, like the opt-in flag: leaves a pending order for manual portal approval. + _leavePending = Environment.GetEnvironmentVariable("CERTINEXT_PRIVATE_PKI_LEAVE_PENDING")?.Trim() == "1"; _v2CredsPresent = !string.IsNullOrWhiteSpace(_v2ApiUrl) && !string.IsNullOrWhiteSpace(_v2ClientId) && !string.IsNullOrWhiteSpace(_v2ClientSecret); } + public void Dispose() => _restoreLogging(); + /// /// V2 config for the private-pki order: mirrors V2LifecycleTests.BuildV2Config (V2 /// mode, no V1-only fields, requestor placeholders) with DCV disabled. Private PKI has no DCV @@ -202,7 +211,7 @@ public async Task PrivatePki_V2_EnrollIntranetSsl_ThenRevoke_Live() ProductParameters = new Dictionary { [Constants.EnrollmentParam.ProductFamily] = "private-pki", - [Constants.EnrollmentParam.ProductVariant] = Constants.ApiV2.PrivatePkiVariantIntranetSsl, + [Constants.EnrollmentParam.ProductVariant] = _variant, [Constants.EnrollmentParam.ProductCode] = _productCode, } }; @@ -214,7 +223,7 @@ public async Task PrivatePki_V2_EnrollIntranetSsl_ThenRevoke_Live() }; _output.WriteLine("=== private-pki live enrollment (ONE order, no retries) ==="); - _output.WriteLine($"Family=private-pki, Variant={Constants.ApiV2.PrivatePkiVariantIntranetSsl}, ProductCode={_productCode}"); + _output.WriteLine($"Family=private-pki, Variant={_variant}, ProductCode={_productCode}"); _output.WriteLine($"CN={cn}, SANs: dnsname=[{cn}], ipaddress=[{IpSan}]"); string orderId = null; @@ -323,6 +332,14 @@ private async Task CleanupAsync(CERTInextCAPlugin plugin, CERTInextClient client return; } + if (!issued && _leavePending) + { + _output.WriteLine($"CERTINEXT_PRIVATE_PKI_LEAVE_PENDING=1: leaving order {orderId} pending for manual approval. " + + "Revoke it once issued (scripts/v2/revoke-private-pki.sh), or cancel it with " + + "POST /private-pki-certificates/{id}/cancel and a non-empty \"reason\"."); + return; + } + bool cleanedUp = false; if (issued) { diff --git a/CERTInext.IntegrationTests/V2WildcardSanShapeTests.cs b/CERTInext.IntegrationTests/V2WildcardSanShapeTests.cs index 4804a86..5b6b6b2 100644 --- a/CERTInext.IntegrationTests/V2WildcardSanShapeTests.cs +++ b/CERTInext.IntegrationTests/V2WildcardSanShapeTests.cs @@ -16,6 +16,7 @@ using System.Threading.Tasks; using FluentAssertions; using Keyfactor.AnyGateway.Extensions; +using Keyfactor.Extensions.CAPlugin.CERTInext.API.V2; using Keyfactor.Extensions.CAPlugin.CERTInext.Client; using Keyfactor.PKI.Enums.EJBCA; using Org.BouncyCastle.Asn1; @@ -203,5 +204,93 @@ await V2OrderCleanup.RevokeOrCancelAsync( } } } + + public static IEnumerable RawShapes() => new[] + { + // shape, additionalDomains mode: "omit" | "wildcard" (the plugin's body) + new object[] { "R1-noHeader-wildcardOnlyInCsr", "omit" }, + new object[] { "R2-noHeader-wildcardInAdditionalDomains", "wildcard" }, + }; + + /// + /// Bypasses the plugin and posts the create body directly: no X-Product-Code, CSR inline with + /// CN = apex and SANs apex + *.apex, domain = apex. Only additionalDomains + /// varies, to tell whether CERTInext resolves a wildcard product from the CSR alone (as a + /// customer script that leaves the product to CERTInext appears to). Records the outcome, + /// resolvedProductCode and the raw Track Order body; cleans up a placed order. + /// + [SkippableTheory] + [MemberData(nameof(RawShapes))] + public async Task Probe_Raw_ApexCn_WildcardSan(string shape, string additionalDomainsMode) + { + Skip.If(!_enabled, "CERTINEXT_USE_V2_API not set or V2 credentials not configured — skipping."); + Skip.If(Environment.GetEnvironmentVariable("CERTINEXT_V2_WILDCARD_SAN_PROBE") != "1", + "CERTINEXT_V2_WILDCARD_SAN_PROBE=1 not set — this places real wildcard DV sandbox orders. Skipping."); + + string ts = DateTime.UtcNow.ToString("yyyyMMddHHmmssfff"); + string apex = $"wcraw-{ts}.{_v2Domain}"; + string wildcard = "*." + apex; + var config = BuildV2Config(); + + var request = new V2CreateSslOrderRequest + { + ProductVariant = Constants.ApiV2.ProductVariantDv, + EmailNotifications = Constants.ApiV2.EmailNotificationsConsentOnly, + Requestor = new V2Requestor + { + Name = config.RequestorName, Email = config.RequestorEmail, + Phone = "+10000000000", Designation = "IT Administrator" + }, + Csr = GenerateCsrPem(apex, new[] { apex, wildcard }), + Certificate = new V2CertificateParams + { + Domain = apex, + AdditionalDomains = additionalDomainsMode == "wildcard" ? new List { wildcard } : null + }, + Subscription = new V2SubscriptionParams { ValidityYears = 1 }, + Agreement = new V2AgreementParams { SignerName = config.RequestorName, SignerPlace = config.SignerPlace }, + Remarks = "Keyfactor plugin wildcard-SAN raw probe." + }; + + _output.WriteLine($"SHAPE {shape}: CN={apex}, CSR SANs=[{apex}, {wildcard}], domain={apex}, " + + $"additionalDomains={(request.Certificate.AdditionalDomains == null ? "(omitted)" : wildcard)}, " + + "X-Product-Code=(none)"); + + using var client = new CERTInextClient(config); + string orderId = null; + try + { + V2CreateOrderResponse created; + try + { + created = await client.PlaceOrderV2Async(Constants.ApiV2.FamilySsl, null, request); + } + catch (Exception ex) + { + _output.WriteLine($"RESULT {shape}: REJECTED {ex.GetType().Name}: {ex.Message}"); + return; + } + + orderId = string.IsNullOrWhiteSpace(created.OrderId) ? null : created.OrderId; + _output.WriteLine($"RESULT {shape}: OrderId={orderId ?? "(none)"}, Status={created.Status}, " + + $"ResolvedProductCode={created.ResolvedProductCode ?? "(not reported)"}"); + + if (orderId != null) + { + var (status, _, body) = await client.ProbeV2GetAsync($"{Constants.ApiV2.SslCertificatesPath}/{orderId}"); + string masked = System.Text.RegularExpressions.Regex.Replace( + body ?? string.Empty, @"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}", ""); + _output.WriteLine($"TRACK {shape}: HTTP {status} {masked}"); + } + } + finally + { + if (orderId != null) + { + await V2OrderCleanup.RevokeOrCancelAsync( + client, orderId, "V2 wildcard-SAN raw probe cleanup.", _output.WriteLine); + } + } + } } } diff --git a/docsource/development.md b/docsource/development.md index c10c555..1576de2 100644 --- a/docsource/development.md +++ b/docsource/development.md @@ -59,12 +59,12 @@ Tests that place real orders, publish DNS records, or cancel orders run only whe |---|---| | `CERTINEXT_COMPLETE_PENDING` | Complete every pending DV order (needs Cloudflare) | | `CERTINEXT_RUN_BULK_TEST`, `CERTINEXT_V2_RUN_BULK_TEST` | V1 and V2 bulk enrollment and pagination tests | -| `CERTINEXT_PRIVATE_PKI_LIVE` | One live Private PKI order and revoke | +| `CERTINEXT_PRIVATE_PKI_LIVE` | One live Private PKI order and revoke. `CERTINEXT_PRIVATE_PKI_VARIANT` picks the variant (default `intranet-ssl`); `CERTINEXT_PRIVATE_PKI_LEAVE_PENDING=1` leaves an unissued order for manual approval instead of cancelling it | | `CERTINEXT_V2_OPS_TESTS` | V2 order-window sweep (maintenance tool) | | `CERTINEXT_V2_LIFECYCLE_DV_UCC`, `_OV`, `_OV_UCC`, `_EV`, `_WILDCARD_DV`, `_RENEW_REISSUE`, `_FRESH_DCV` | The matching V2 full-lifecycle test | | `CERTINEXT_V2_LIFECYCLE_REISSUE_ENDPOINT` (plus `CERTINEXT_V2_REISSUE_SOURCE_ORDER_ID`) | One reissue of an issued order through `/reissue`; creates a derived order and cleans it up | | `CERTINEXT_V2_SSLCOM_DCV_PROBE`, `CERTINEXT_V2_UNRESOLVED_STATUS_PROBE` | Read-only probes: SSL.com domain lookup and DCV shape; report status pairs the sync can't map | -| `CERTINEXT_V2_WILDCARD_SAN_PROBE` | Places DV orders with the CN as the apex and the wildcard only in the SANs, and logs what CERTInext accepts and which product it resolves (`V2WildcardSanShapeTests`) | +| `CERTINEXT_V2_WILDCARD_SAN_PROBE` | Places DV orders with the CN as the apex and the wildcard only in the SANs, and logs what CERTInext accepts and which product it resolves (`V2WildcardSanShapeTests`; `Probe_Raw_ApexCn_WildcardSan` posts the create body directly with no `X-Product-Code`) | | `CERTINEXT_V2_REVOKE_PRIVILEGE_WITHDRAWN` | Places its own DV order and revokes it with `privilege-withdrawn` | Set each to `1`. [INTEGRATION_TESTING.md](../CERTInext.IntegrationTests/INTEGRATION_TESTING.md) lists the remaining flags, such as the algorithm matrices, and the extra variables each test needs. To load `~/.env_certinext` into a shell that also exports a flag, use `set -a; . ~/.env_certinext; set +a`. From e4e735cf3ab2ae1f5cb51825692d8c72ab8fa6cf Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 17 Nov 2026 18:24:53 +0000 Subject: [PATCH 03/12] docs: auto-generate README and documentation [skip ci] --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 611810f..7b9febf 100644 --- a/README.md +++ b/README.md @@ -631,8 +631,8 @@ When `UseV2Api` is `true`, the plugin does not choose a numeric product code. Th 1. **No `ProductCode` on the template (the default)** — no `X-Product-Code` header is sent, with one exception, described below. The connector's `DefaultProductCode` is not used. Save-time validation does no catalog check. The plugin decides whether the order is wildcard or multi-domain from the request itself: - **Wildcard:** the primary domain starts with `*.`. - **Multi-domain:** the selected product is a UCC product, or the CSR or gateway SAN list carries DNS names beyond the primary domain (its `www.` variant, and a wildcard's bare apex, don't count). Those names are sent as `additionalDomains`, which makes CERTInext choose a UCC product. - - **Wildcard in the SANs only (the exception):** the CN is a plain name, such as `example.com`, and a SAN is a wildcard, such as `*.example.com`. CERTInext can't resolve this request itself. It treats an order as wildcard only when `certificate.domain` starts with `*.`, so it picks a plain UCC product and rejects the wildcard with `EMS-1173 Invalid Additional Domain Names`. Sending the wildcard as the domain doesn't work either: CERTInext requires the domain to match the CSR CN (`EMS-1056`). For this case, the plugin reads the account's catalog once. If the catalog has exactly one active Wildcard UCC product for the variant (`productTypeID` `21` for DV, `22` for OV), the plugin sends that product's code as `X-Product-Code`. It keeps the CN as the domain and sends the wildcard in `additionalDomains`. If no single product matches, or the catalog can't be read, enrollment fails before any order is placed, and the message asks you to set `ProductCode` on the template. Setting it also skips the lookup. EV has no wildcard product, so EV requests in this shape are rejected. -2. **Explicit `ProductCode` (or the deprecated `ProfileId` alias)** — the override. It is sent as-is in the `X-Product-Code` header, after template save-time validation confirms it exists in the live V2 catalog and matches the selected product. Use it when your account holds several matching products (for example different CA profiles for the same variant) and you want to force one. With an override, the plugin reads the catalog once per enrollment to recognize UCC and wildcard products, and rejects extra SANs on a single-domain product. + - **Wildcard in the SANs only (the exception):** the CN is a plain name, such as `example.com`, and a SAN is a wildcard, such as `*.example.com`. On some accounts CERTInext can't resolve this request itself. It treats an order as wildcard only when `certificate.domain` starts with `*.`, so it picks a plain UCC product and rejects the wildcard with `EMS-1173 Invalid Additional Domain Names`. Sending the wildcard as the domain doesn't work either: CERTInext requires the domain to match the CSR CN (`EMS-1056`). For this case, the plugin reads the account's catalog once. If the catalog has exactly one active Wildcard UCC product for the variant (`productTypeID` `21` for DV, `22` for OV), the plugin sends that product's code as `X-Product-Code`. It keeps the CN as the domain and sends the wildcard in `additionalDomains`. If no single product matches, or the catalog can't be read, the plugin logs a warning and places the order without `X-Product-Code`, leaving the product to CERTInext. Catalogs on other CA backends (such as SSL.com) need not use these `productTypeID` values. If CERTInext then rejects the wildcard (`EMS-1173`), the error asks you to set `ProductCode` on the template, which also skips the lookup. EV has no wildcard product, so EV requests in this shape are rejected before any order is placed. +2. **Explicit `ProductCode` (or the deprecated `ProfileId` alias)** — the override. It is sent as-is in the `X-Product-Code` header, after template save-time validation confirms it exists in the live V2 catalog and matches the selected product. The match is checked only when the catalog entry has a documented SSL `productTypeID`; otherwise the code is accepted as given. Use it when your account holds several matching products (for example different CA profiles for the same variant) and you want to force one. With an override, the plugin reads the catalog once per enrollment to recognize UCC and wildcard products. When the catalog entry has a documented SSL `productTypeID` (`13`-`22`), a single-domain product rejects extra SANs. When it doesn't (the code isn't listed, the entry has no or an unfamiliar `productTypeID`, or the catalog can't be read), the plugin decides from the request the same way as without an override: extra DNS names make it multi-domain and go out in `additionalDomains`, and CERTInext rejects the code if it can't carry them. This differs from V1, where `DefaultProductCode` only affects renewals (see [DefaultProductCode](#defaultproductcode)). From e8f8a38161e27bcd04c552cf7d9ed0d68a1b4971 Mon Sep 17 00:00:00 2001 From: spbsoluble <1661003+spbsoluble@users.noreply.github.com> Date: Tue, 17 Nov 2026 10:38:13 -0800 Subject: [PATCH 04/12] fix(v2): never add X-Product-Code on the plugin's own; send a template ProductCode as given CERTInext advises sending only the variant and leaving X-Product-Code out. Removes the catalog lookup that pinned a Wildcard UCC product (typeID 21/22) for a wildcard SAN on a plain CN, along with its no-match fallback and EMS-1173 hint. That request now goes out like any other: CN as the domain, the wildcard in additionalDomains, no header unless the template sets ProductCode, no catalog call. EV with a wildcard SAN is still rejected before ordering. Drops the now-unused WildcardUccProductTypeIdByVariant. --- .../V2WildcardSanShapeTests.cs | 9 +- .../V2ProductCodeResolutionTests.cs | 123 +++------------ CERTInext/CERTInextCAPlugin.cs | 142 ++++-------------- CERTInext/Constants.cs | 11 -- CHANGELOG.md | 2 +- docsource/configuration.md | 8 +- 6 files changed, 60 insertions(+), 235 deletions(-) diff --git a/CERTInext.IntegrationTests/V2WildcardSanShapeTests.cs b/CERTInext.IntegrationTests/V2WildcardSanShapeTests.cs index 5b6b6b2..be74f06 100644 --- a/CERTInext.IntegrationTests/V2WildcardSanShapeTests.cs +++ b/CERTInext.IntegrationTests/V2WildcardSanShapeTests.cs @@ -6,9 +6,10 @@ // and limitations under the License. // // Wildcard-in-the-SAN-only enrollments (issue 0099): the CSR's CN is the apex and the wildcard is -// only in the SAN set. CERTInext's wrapper decides "wildcard" from certificate.domain alone, so the -// plugin must send the wildcard as the domain. These probes place real sandbox orders and record -// what CERTInext accepts and which product it resolves; gated by CERTINEXT_V2_WILDCARD_SAN_PROBE=1. +// only in the SAN set. The plugin keeps the CN as certificate.domain and sends the wildcard in +// additionalDomains, with no X-Product-Code unless the template sets ProductCode. These probes +// place real sandbox orders and record what CERTInext accepts and which product it resolves; gated +// by CERTINEXT_V2_WILDCARD_SAN_PROBE=1. using System; using System.Collections.Generic; @@ -107,7 +108,7 @@ private static string GenerateCsrPem(string commonName, IReadOnlyList dn /// /// Read-only: lists the account's live catalog entries with their productTypeID, so a run - /// shows which Wildcard UCC products (typeID 21 DV / 22 OV) the plugin can resolve to. + /// shows the catalog codes and productTypeIDs an explicit template ProductCode can be checked against. /// [SkippableFact] public async Task Catalog_ListsProductTypeIds() diff --git a/CERTInext.Tests/V2ProductCodeResolutionTests.cs b/CERTInext.Tests/V2ProductCodeResolutionTests.cs index 992ca61..ab03a30 100644 --- a/CERTInext.Tests/V2ProductCodeResolutionTests.cs +++ b/CERTInext.Tests/V2ProductCodeResolutionTests.cs @@ -224,140 +224,59 @@ public async Task NoExplicitProductCode_PrimaryDomainAndWwwVariantOnly_IsNotUcc( cap.Request.Certificate.AdditionalDomains.Should().BeNull(); } - private static List SandboxSslCatalog() => new List - { - new ProductDetail { ProductCode = "842", ProductTypeId = "13", Active = true }, // DV SSL - new ProductDetail { ProductCode = "843", ProductTypeId = "14", Active = true }, // DV SSL Wildcard - new ProductDetail { ProductCode = "844", ProductTypeId = "15", Active = true }, // DV SSL UCC - new ProductDetail { ProductCode = "845", ProductTypeId = "21", Active = true }, // DV SSL Wildcard UCC - new ProductDetail { ProductCode = "849", ProductTypeId = "22", Active = true }, // OV SSL Wildcard UCC - }; - - // CN = apex, wildcard only in the SANs: the wrapper would resolve a plain UCC product and - // reject the wildcard additional domain (EMS-1173), and a wildcard domain that differs from - // the CN is rejected too (EMS-1056), so the plugin must name the Wildcard UCC product. + // CN = apex, wildcard only in the SANs. CERTInext's guidance is to send only the variant, so the + // plugin sends no X-Product-Code and doesn't read the catalog: the wildcard goes out in + // additionalDomains and CERTInext picks the product. [Theory] - [InlineData("DV SSL", null, "845")] - [InlineData("OV SSL", "ORG-1", "849")] - public async Task NoExplicitProductCode_WildcardSanOnApexCn_SendsTheCatalogsWildcardUccCode( - string productId, string organizationNumber, string expectedCode) + [InlineData("DV SSL", null, "dv")] + [InlineData("OV SSL", "ORG-1", "ov")] + public async Task NoExplicitProductCode_WildcardSanOnApexCn_SendsNoCode_WildcardInAdditionalDomains( + string productId, string organizationNumber, string expectedVariant) { var (mock, cap) = NewSslMock(); - mock.Setup(c => c.GetProductDetailsV2Async(It.IsAny())).ReturnsAsync(SandboxSslCatalog()); var plugin = new CERTInextCAPlugin(mock.Object, Config(organizationNumber: organizationNumber)); var result = await EnrollAsync(plugin, ProductInfo(productId), "example.com", "*.example.com"); result.CARequestID.Should().Be(OrderId); - cap.ProductCode.Should().Be(expectedCode); + cap.ProductCode.Should().BeNull("the plugin never adds X-Product-Code on its own"); + cap.Request.ProductVariant.Should().Be(expectedVariant); cap.Request.Certificate.Domain.Should().Be("example.com", "certificate.domain must stay equal to the CSR CN"); cap.Request.Certificate.AdditionalDomains.Should().Equal("*.example.com"); + mock.Verify(c => c.GetProductDetailsV2Async(It.IsAny()), Times.Never); } [Fact] - public async Task NoExplicitProductCode_WildcardSanOnApexCn_WithAnotherName_StillWildcardUcc() + public async Task NoExplicitProductCode_WildcardSanOnApexCn_WithAnotherName_SendsNoCode() { var (mock, cap) = NewSslMock(); - mock.Setup(c => c.GetProductDetailsV2Async(It.IsAny())).ReturnsAsync(SandboxSslCatalog()); var plugin = new CERTInextCAPlugin(mock.Object, Config()); await EnrollAsync(plugin, ProductInfo(Constants.Products.DvSsl), "example.com", "*.example.com", "other.example.org"); - cap.ProductCode.Should().Be("845"); + cap.ProductCode.Should().BeNull(); cap.Request.Certificate.AdditionalDomains.Should().BeEquivalentTo("*.example.com", "other.example.org"); - } - - public static IEnumerable UnresolvableCatalogs() => new[] - { - new object[] { "none", new List { new ProductDetail { ProductCode = "844", ProductTypeId = "15", Active = true } } }, - new object[] { "inactive", new List { new ProductDetail { ProductCode = "845", ProductTypeId = "21", Active = false } } }, - new object[] { "several", new List - { - new ProductDetail { ProductCode = "845", ProductTypeId = "21", Active = true }, - new ProductDetail { ProductCode = "1021", ProductTypeId = "21", Active = true }, - } }, - // A catalog on another CA backend (SSL.com) whose entries carry no documented productTypeID. - new object[] { "no type ids", new List - { - new ProductDetail { ProductCode = "1011", Active = true }, - new ProductDetail { ProductCode = "1012", ProductTypeId = "101", Active = true }, - } }, - }; - - // The catalog names no single Wildcard UCC product: the order goes out unpinned and CERTInext - // picks the product, as a customer's direct API call of this shape does (and issues). - [Theory] - [MemberData(nameof(UnresolvableCatalogs))] - public async Task NoExplicitProductCode_WildcardSanOnApexCn_NoSingleWildcardUccProduct_PlacesUnpinned( - string label, List catalog) - { - using var capture = new PluginLogCapture(); - var (mock, cap) = NewSslMock(); - mock.Setup(c => c.GetProductDetailsV2Async(It.IsAny())).ReturnsAsync(catalog); - var plugin = new CERTInextCAPlugin(mock.Object, Config()); - - var result = await EnrollAsync(plugin, ProductInfo(Constants.Products.DvSsl), "example.com", "*.example.com"); - - result.CARequestID.Should().Be(OrderId, label); - cap.Placed.Should().BeTrue(label); - cap.ProductCode.Should().BeNull(label); - cap.Request.Certificate.Domain.Should().Be("example.com"); - cap.Request.Certificate.AdditionalDomains.Should().Equal("*.example.com"); - capture.Lines(LogLevel.Warning, "Sending no X-Product-Code").Should().ContainSingle(label); + mock.Verify(c => c.GetProductDetailsV2Async(It.IsAny()), Times.Never); } [Fact] - public async Task NoExplicitProductCode_WildcardSanOnApexCn_CatalogUnavailable_PlacesUnpinned() + public async Task ExplicitProductCode_WildcardUccCatalogEntry_WildcardSanOnApexCn_SendsTheTemplatesCode() { var (mock, cap) = NewSslMock(); mock.Setup(c => c.GetProductDetailsV2Async(It.IsAny())) - .ThrowsAsync(new Exception("catalog down")); + .ReturnsAsync(new List + { + new ProductDetail { ProductCode = "845", ProductTypeId = "21", Active = true } // DV SSL Wildcard UCC + }); var plugin = new CERTInextCAPlugin(mock.Object, Config()); - var result = await EnrollAsync(plugin, ProductInfo(Constants.Products.DvSsl), "example.com", "*.example.com"); + await EnrollAsync(plugin, ProductInfo(Constants.Products.DvSslWildcardUcc, productCode: "845"), + "example.com", "*.example.com"); - result.CARequestID.Should().Be(OrderId); - cap.ProductCode.Should().BeNull(); + cap.ProductCode.Should().Be("845", "an explicit template ProductCode is sent as given"); cap.Request.Certificate.AdditionalDomains.Should().Equal("*.example.com"); } - [Fact] - public async Task NoExplicitProductCode_WildcardSanOnApexCn_Unpinned_Ems1173_SaysToSetProductCode() - { - var mock = new Mock(MockBehavior.Strict); - mock.Setup(c => c.GetProductDetailsV2Async(It.IsAny())) - .ReturnsAsync(new List()); - mock.Setup(c => c.PlaceOrderV2Async( - It.IsAny(), It.IsAny(), - It.IsAny(), It.IsAny())) - .ThrowsAsync(new Exception( - "CERTInext V2 API error during 'V2 place order'. HTTP 422. Unprocessable Entity: " + - "[EMS-1173] Invalid Additional Domain Names (*.example.com)")); - var plugin = new CERTInextCAPlugin(mock.Object, Config()); - - Func act = () => EnrollAsync(plugin, ProductInfo(Constants.Products.DvSsl), "example.com", "*.example.com"); - - (await act.Should().ThrowAsync()) - .Which.Message.Should().Contain("EMS-1173").And.Contain("Set ProductCode on the template"); - } - - [Fact] - public async Task NoExplicitProductCode_PlainUcc_Ems1173_IsNotReworded() - { - var mock = new Mock(MockBehavior.Strict); - const string caError = "CERTInext V2 API error during 'V2 place order'. HTTP 422. Unprocessable Entity: " + - "[EMS-1173] Invalid Additional Domain Names (bad..example.com)"; - mock.Setup(c => c.PlaceOrderV2Async( - It.IsAny(), It.IsAny(), - It.IsAny(), It.IsAny())) - .ThrowsAsync(new Exception(caError)); - var plugin = new CERTInextCAPlugin(mock.Object, Config()); - - Func act = () => EnrollAsync(plugin, ProductInfo(Constants.Products.DvSsl), "example.com", "other.example.com"); - - (await act.Should().ThrowAsync()).Which.Message.Should().Be(caError); - } - // Explicit ProductCode whose catalog entry doesn't carry a documented SSL productTypeID (code not // listed, no type, an unfamiliar type, or no catalog): the request decides, so the wildcard SAN // goes out in additionalDomains instead of being rejected as an extra SAN. diff --git a/CERTInext/CERTInextCAPlugin.cs b/CERTInext/CERTInextCAPlugin.cs index 1855312..99fc03a 100644 --- a/CERTInext/CERTInextCAPlugin.cs +++ b/CERTInext/CERTInextCAPlugin.cs @@ -1803,50 +1803,6 @@ internal static List FindExtraDnsSans( .ToList(); } - /// - /// The account's Wildcard UCC product code for an SSL - /// that has one (DV/OV; the caller rejects EV first), read from the live V2 catalog: the single - /// active product whose productTypeID is 's - /// entry for the variant. Returns (code, null) on success, else (null, reason) - /// when the catalog could not be read or lists zero or several matches. The caller then sends - /// no X-Product-Code and leaves the product to CERTInext: catalogs on other CA backends - /// (SSL.com) need not carry these productTypeIDs, and there CERTInext accepts this shape - /// unpinned (reported by a customer; not reproducible on our emSign sandbox). - /// - private async Task<(string ProductCode, string Unresolved)> ResolveWildcardUccProductCodeAsync(string productVariant) - { - string typeId = Constants.ApiV2.WildcardUccProductTypeIdByVariant[productVariant]; - - List catalog; - try - { - catalog = await _client.GetProductDetailsV2Async(); - } - catch (Exception ex) - { - _logger.LogWarning(ex, "EnrollV2Async: could not read the V2 product catalog to resolve a Wildcard UCC product."); - return (null, "The product catalog could not be read to find the Wildcard UCC product."); - } - - var matches = (catalog ?? new List()) - .Where(p => p.Active && string.Equals(p.ProductTypeId, typeId, StringComparison.Ordinal) - && !string.IsNullOrWhiteSpace(p.ProductCode)) - .Select(p => p.ProductCode) - .Distinct(StringComparer.OrdinalIgnoreCase) - .ToList(); - if (matches.Count == 1) - { - _logger.LogInformation( - "EnrollV2Async: resolved Wildcard UCC product {ProductCode} (productTypeID {TypeId}) for a wildcard SAN " + - "on a non-wildcard domain.", matches[0], typeId); - return (matches[0], null); - } - - return (null, matches.Count == 0 - ? $"The account's catalog has no active Wildcard UCC product (productTypeID {typeId})." - : $"The account's catalog has several active Wildcard UCC products ({string.Join(", ", matches)})."); - } - /// /// Validates the template parameters a V2 private-pki order needs /// beyond the SSL ones, before any CA call. Shared by (fail @@ -2323,7 +2279,9 @@ private async Task EnrollV2CoreAsync( // matching catalog products. The connector's DefaultProductCode no longer pins a V2 // order (it remains a V1 renewal fallback), and the V1-era Constants.Products. // DefaultProductCodes table is never consulted (its numbering does not match the live - // V2 catalog). A null productCode means "send no header". + // V2 catalog). A null productCode means "send no header". CERTInext has also told us + // directly to send only the variant and leave X-Product-Code out, so the plugin never + // adds it on its own, for any request shape. // // UCC / wildcard detection decides whether extra DNS SANs are carried in // additionalDomains (UCC) or rejected by the single-domain guard below: @@ -2338,12 +2296,8 @@ private async Task EnrollV2CoreAsync( // type (ProductId -> productTypeID, as before) OR the request carrying DNS SANs // beyond the primary domain (its www. variant and a wildcard's bare apex are not // "extra"), which is what makes the wrapper pick a UCC product — so those extras go - // out in additionalDomains instead of failing the single-domain guard. - // One exception reads the catalog: a wildcard SAN on a non-wildcard domain (CN = - // apex, SAN = *.apex) needs a Wildcard UCC product the wrapper cannot infer on our - // emSign sandbox, so the account's one is resolved and sent - // (ResolveWildcardUccProductCodeAsync). If the catalog doesn't name exactly one, no - // code is sent and CERTInext decides. + // out in additionalDomains instead of failing the single-domain guard. That includes a + // wildcard SAN on a non-wildcard domain (CN = apex, SAN = *.apex). // // Private PKI: ProductCode is likewise optional (the wrapper resolves it from // `variant`); the catalog is never fetched because its only use on this path — SSL UCC @@ -2351,9 +2305,6 @@ private async Task EnrollV2CoreAsync( string productCode = ep.HasExplicitProductCode ? ep.ProductCode : null; bool isUccProduct = false; bool isWildcardProduct = false; - // Set when a wildcard SAN on a non-wildcard domain goes out with no X-Product-Code, so an - // EMS-1173 from the create can say how to pin the product. - bool wildcardSanUnpinned = false; if (!isPrivatePki && ep.HasExplicitProductCode) { List catalog = null; @@ -2397,58 +2348,33 @@ private async Task EnrollV2CoreAsync( var extraDnsSans = FindExtraDnsSans(csr, san, domain, isWildcardProduct); isUccProduct = templateIsUccType || extraDnsSans.Count > 0; - // Wildcard only in the SANs (CN = the apex, SAN = *.apex): the wrapper keys - // "wildcard" on certificate.domain alone, so it resolves a plain UCC product and - // rejects the wildcard additional domain (EMS-1173). Sending the wildcard as the - // domain instead is rejected too, because the domain must match the CSR CN - // (EMS-1056). Both confirmed live on our emSign sandbox (V2WildcardSanShapeTests). The - // order there needs a Wildcard UCC product, which only an explicit X-Product-Code - // selects, so resolve the account's one from the catalog. When the catalog doesn't - // name exactly one (seen on a customer's account, likely SSL.com-backed, whose direct - // unpinned orders of this shape issue), send no code and let CERTInext decide. EV has - // no wildcard product at all, so that still fails before placing an order. - if (!isWildcardProduct && extraDnsSans.Any(s => s.StartsWith("*.", StringComparison.Ordinal))) + // Wildcard only in the SANs (CN = the apex, SAN = *.apex): the wildcard goes out in + // additionalDomains like any other extra name, and CERTInext picks the product. EV has + // no wildcard product at all, so that fails before placing an order. + if (!isWildcardProduct + && string.Equals(sslProductVariant, Constants.ApiV2.ProductVariantEv, StringComparison.OrdinalIgnoreCase) + && extraDnsSans.Any(s => s.StartsWith("*.", StringComparison.Ordinal))) { - if (!Constants.ApiV2.WildcardUccProductTypeIdByVariant.ContainsKey(sslProductVariant ?? string.Empty)) - { - _logger.LogError( - "EnrollV2Async rejected an order with a wildcard SAN on a non-wildcard domain '{Domain}': " + - "product variant '{Variant}' has no wildcard product.", - LogSanitizer.Strip(domain), sslProductVariant); - _logger.MethodExit(LogLevel.Debug); - return new EnrollmentResult - { - CARequestID = string.Empty, - Certificate = null, - Status = (int)EndEntityStatus.FAILED, - StatusMessage = $"V2 enrollment rejected: the request carries a wildcard SAN but its " + - $"primary domain ('{domain}', the CSR CN) is not a wildcard, which needs " + - $"a Wildcard UCC product. Product variant '{sslProductVariant}' has no " + - "wildcard product. No order was placed." - }; - } - - string unresolved; - (productCode, unresolved) = await ResolveWildcardUccProductCodeAsync(sslProductVariant); - if (productCode == null) + _logger.LogError( + "EnrollV2Async rejected an EV order with a wildcard SAN on domain '{Domain}': EV has no " + + "wildcard product.", LogSanitizer.Strip(domain)); + _logger.MethodExit(LogLevel.Debug); + return new EnrollmentResult { - wildcardSanUnpinned = true; - _logger.LogWarning( - "EnrollV2Async: wildcard SAN on non-wildcard domain '{Domain}' with no Wildcard UCC product " + - "code to send: {Reason} Sending no X-Product-Code; CERTInext resolves the product. If it " + - "rejects the wildcard (EMS-1173), set ProductCode on the template.", - LogSanitizer.Strip(domain), unresolved); - } + CARequestID = string.Empty, + Certificate = null, + Status = (int)EndEntityStatus.FAILED, + StatusMessage = $"V2 enrollment rejected: the request carries a wildcard SAN, but EV has " + + $"no wildcard product (primary domain '{domain}'). No order was placed." + }; } _logger.LogInformation( - "EnrollV2Async: no explicit ProductCode on the template. CERTInext resolves the product from " + - "the variant, wildcard shape and additional domains unless a wildcard SAN on a non-wildcard " + - "domain needed a Wildcard UCC code. ProductId={ProductId}, Wildcard={Wildcard}, Ucc={Ucc} " + - "(TemplateUccType={TemplateUccType}, ExtraDnsSanCount={ExtraCount}), " + - "XProductCode={ProductCode}", - ep.ProductId, isWildcardProduct, isUccProduct, templateIsUccType, extraDnsSans.Count, - productCode ?? "(none)"); + "EnrollV2Async: no explicit ProductCode on the template — no X-Product-Code header will be sent; " + + "CERTInext resolves the product from the variant, wildcard shape and additional domains. " + + "ProductId={ProductId}, Wildcard={Wildcard}, Ucc={Ucc} (TemplateUccType={TemplateUccType}, " + + "ExtraDnsSanCount={ExtraCount})", + ep.ProductId, isWildcardProduct, isUccProduct, templateIsUccType, extraDnsSans.Count); } // Non-UCC V2 products support only a single domain plus autoSecureWww's www. @@ -2753,19 +2679,7 @@ await EnsureSslComOrganizationValidationAsync( Remarks = remarks, GroupNumber = groupNumber }; - try - { - createResp = await _client.PlaceOrderV2Async(ep.ProductFamilySlug, productCode, orderReq); - } - catch (Exception createEx) when (wildcardSanUnpinned - && createEx.Message?.IndexOf("EMS-1173", StringComparison.OrdinalIgnoreCase) >= 0) - { - // CERTInext picked a product that can't carry the wildcard additional domain. - throw new Exception( - $"{createEx.Message} The request carries a wildcard SAN on a non-wildcard primary domain " + - "and the catalog named no single Wildcard UCC product to send. Set ProductCode on the " + - "template to the account's Wildcard UCC product code.", createEx); - } + createResp = await _client.PlaceOrderV2Async(ep.ProductFamilySlug, productCode, orderReq); } string orderId = createResp.OrderId; diff --git a/CERTInext/Constants.cs b/CERTInext/Constants.cs index 9ed03b6..aa3a355 100644 --- a/CERTInext/Constants.cs +++ b/CERTInext/Constants.cs @@ -643,17 +643,6 @@ public static class ApiV2 public static readonly System.Collections.Generic.HashSet WildcardProductTypeIds = new System.Collections.Generic.HashSet { "14", "17" }; - // Wildcard UCC productTypeID per SSL productVariant (live catalog: 21=DV SSL Wildcard - // UCC, 22=OV SSL Wildcard UCC; EV has no wildcard product). Used when the wildcard is - // only in the SANs: the wrapper keys "wildcard" on certificate.domain alone, and the - // domain must equal the CSR CN (EMS-1056), so the plugin has to name the product itself. - public static readonly System.Collections.Generic.Dictionary WildcardUccProductTypeIdByVariant = - new System.Collections.Generic.Dictionary(System.StringComparer.OrdinalIgnoreCase) - { - [ProductVariantDv] = "21", - [ProductVariantOv] = "22", - }; - // Orders report (Synchronize, V2 mode) — GET /api/certinext/v2/reports/orders. // Spring-style page envelope: content/page/size/totalPages/totalElements. // Paging is 1-based; size is clamped to 100 server-side; page=0 is treated as diff --git a/CHANGELOG.md b/CHANGELOG.md index f68e418..e9fd3ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,7 +21,7 @@ - feat(config): V2 orders honor `GroupNumber`, `OrganizationNumber`, `TechnicalContact*`, `EmailNotifications`, and the subscription renewal settings. ## Bug Fixes -- fix(v2): A DV or OV request whose CN is a plain name and whose SANs carry a wildcard (CN `example.com`, SAN `*.example.com`) no longer fails with `EMS-1173 Invalid Additional Domain Names`. CERTInext treats an order as wildcard only when its domain is a wildcard, and it rejects a domain that differs from the CN (`EMS-1056`). With no `ProductCode` on the template, the plugin now looks up the account's single active Wildcard UCC product in the catalog and sends its code. If there isn't exactly one, or the catalog can't be read, the order is placed without `X-Product-Code` and CERTInext picks the product, as accounts on other CA backends (such as SSL.com) need; an `EMS-1173` from CERTInext then asks you to set `ProductCode`. EV requests in this shape are still rejected before ordering. +- fix(v2): A request whose CN is a plain name and whose SANs carry a wildcard (CN `example.com`, SAN `*.example.com`) keeps the CN as the domain and sends the wildcard in `additionalDomains`, with no `X-Product-Code` unless the template sets `ProductCode` (CERTInext's guidance is to send only the variant). An EV request in this shape is rejected before ordering, since EV has no wildcard product. - fix(v2): With an explicit `ProductCode` whose catalog entry has no documented SSL `productTypeID` (not listed, no type, an unfamiliar type, or an unreadable catalog), extra SANs (including a wildcard SAN) are sent as `additionalDomains` instead of being rejected as a single-domain order. Template save-time validation likewise accepts such a code instead of rejecting it as a product mismatch. - fix(v2): Flat catalog rows with a `productCode` key are read as available when they have no `active` field, and a numeric `productTypeID` no longer fails the catalog read. - fix(v2): A 422 `EMS-1165` from Download Certificate on an order CERTInext reports as `issued` is treated as "certificate not generated yet": the enrollment pickup keeps polling and returns pending, logging per attempt at Debug and one Information summary instead of a warning each time. `GetSingleRecord` and Synchronize log it quietly too (the sync summary gains `IssuedNotGeneratedYet`), and the log lines include CERTInext's `orderState` and `certificateState`. Other download errors still warn. diff --git a/docsource/configuration.md b/docsource/configuration.md index 531d2a5..34a5b9a 100644 --- a/docsource/configuration.md +++ b/docsource/configuration.md @@ -575,11 +575,13 @@ When `UseV2Api` is `true`, two additional enrollment parameters become relevant: When `UseV2Api` is `true`, the plugin does not choose a numeric product code. The V2 spec treats the `X-Product-Code` header on order create as an optional override: CERTInext's wrapper picks the right catalog product from the variant (`productVariant` for SSL/TLS, `variant` for Private PKI), whether `certificate.domain` is a wildcard (it starts with `*.`), and whether `additionalDomains` is non-empty (multi-domain, UCC). The create response reports the product it chose as `resolvedProductCode`, which the plugin logs at Information level. -1. **No `ProductCode` on the template (the default)** — no `X-Product-Code` header is sent, with one exception, described below. The connector's `DefaultProductCode` is not used. Save-time validation does no catalog check. The plugin decides whether the order is wildcard or multi-domain from the request itself: +CERTInext advises sending only the variant and leaving `X-Product-Code` out, so the plugin never adds the header on its own. + +1. **No `ProductCode` on the template (the default and recommended)** — no `X-Product-Code` header is sent. The connector's `DefaultProductCode` is not used. Neither save-time validation nor enrollment reads the catalog. The plugin decides whether the order is wildcard or multi-domain from the request itself: - **Wildcard:** the primary domain starts with `*.`. - **Multi-domain:** the selected product is a UCC product, or the CSR or gateway SAN list carries DNS names beyond the primary domain (its `www.` variant, and a wildcard's bare apex, don't count). Those names are sent as `additionalDomains`, which makes CERTInext choose a UCC product. - - **Wildcard in the SANs only (the exception):** the CN is a plain name, such as `example.com`, and a SAN is a wildcard, such as `*.example.com`. On some accounts CERTInext can't resolve this request itself. It treats an order as wildcard only when `certificate.domain` starts with `*.`, so it picks a plain UCC product and rejects the wildcard with `EMS-1173 Invalid Additional Domain Names`. Sending the wildcard as the domain doesn't work either: CERTInext requires the domain to match the CSR CN (`EMS-1056`). For this case, the plugin reads the account's catalog once. If the catalog has exactly one active Wildcard UCC product for the variant (`productTypeID` `21` for DV, `22` for OV), the plugin sends that product's code as `X-Product-Code`. It keeps the CN as the domain and sends the wildcard in `additionalDomains`. If no single product matches, or the catalog can't be read, the plugin logs a warning and places the order without `X-Product-Code`, leaving the product to CERTInext. Catalogs on other CA backends (such as SSL.com) need not use these `productTypeID` values. If CERTInext then rejects the wildcard (`EMS-1173`), the error asks you to set `ProductCode` on the template, which also skips the lookup. EV has no wildcard product, so EV requests in this shape are rejected before any order is placed. -2. **Explicit `ProductCode` (or the deprecated `ProfileId` alias)** — the override. It is sent as-is in the `X-Product-Code` header, after template save-time validation confirms it exists in the live V2 catalog and matches the selected product. The match is checked only when the catalog entry has a documented SSL `productTypeID`; otherwise the code is accepted as given. Use it when your account holds several matching products (for example different CA profiles for the same variant) and you want to force one. With an override, the plugin reads the catalog once per enrollment to recognize UCC and wildcard products. When the catalog entry has a documented SSL `productTypeID` (`13`-`22`), a single-domain product rejects extra SANs. When it doesn't (the code isn't listed, the entry has no or an unfamiliar `productTypeID`, or the catalog can't be read), the plugin decides from the request the same way as without an override: extra DNS names make it multi-domain and go out in `additionalDomains`, and CERTInext rejects the code if it can't carry them. + - **Wildcard in the SANs only:** the CN is a plain name, such as `example.com`, and a SAN is a wildcard, such as `*.example.com`. The CN stays the domain (CERTInext requires the domain to match the CSR CN, `EMS-1056`), and the wildcard is sent in `additionalDomains`. EV has no wildcard product, so EV requests in this shape are rejected before any order is placed. +2. **Explicit `ProductCode` (or the deprecated `ProfileId` alias)** — the override. It is sent as-is in the `X-Product-Code` header, after template save-time validation confirms it exists in the live V2 catalog and matches the selected product. The match is checked only when the catalog entry has a documented SSL `productTypeID`; otherwise the code is accepted as given. CERTInext advises against sending it, so use it only when your account holds several matching products (for example different CA profiles for the same variant) and you want to force one. With an override, the plugin reads the catalog once per enrollment to recognize UCC and wildcard products. When the catalog entry has a documented SSL `productTypeID` (`13`-`22`), a single-domain product rejects extra SANs. When it doesn't (the code isn't listed, the entry has no or an unfamiliar `productTypeID`, or the catalog can't be read), the plugin decides from the request the same way as without an override: extra DNS names make it multi-domain and go out in `additionalDomains`, and CERTInext rejects the code if it can't carry them. This differs from V1, where `DefaultProductCode` only affects renewals (see [DefaultProductCode](#defaultproductcode)). From 0ff7d2650ce49f6a4712fe0c97120b12c23a90af Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 17 Nov 2026 18:39:00 +0000 Subject: [PATCH 05/12] docs: auto-generate README and documentation [skip ci] --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7b9febf..b9fc8ff 100644 --- a/README.md +++ b/README.md @@ -628,11 +628,13 @@ When `UseV2Api` is `true`, two additional enrollment parameters become relevant: When `UseV2Api` is `true`, the plugin does not choose a numeric product code. The V2 spec treats the `X-Product-Code` header on order create as an optional override: CERTInext's wrapper picks the right catalog product from the variant (`productVariant` for SSL/TLS, `variant` for Private PKI), whether `certificate.domain` is a wildcard (it starts with `*.`), and whether `additionalDomains` is non-empty (multi-domain, UCC). The create response reports the product it chose as `resolvedProductCode`, which the plugin logs at Information level. -1. **No `ProductCode` on the template (the default)** — no `X-Product-Code` header is sent, with one exception, described below. The connector's `DefaultProductCode` is not used. Save-time validation does no catalog check. The plugin decides whether the order is wildcard or multi-domain from the request itself: +CERTInext advises sending only the variant and leaving `X-Product-Code` out, so the plugin never adds the header on its own. + +1. **No `ProductCode` on the template (the default and recommended)** — no `X-Product-Code` header is sent. The connector's `DefaultProductCode` is not used. Neither save-time validation nor enrollment reads the catalog. The plugin decides whether the order is wildcard or multi-domain from the request itself: - **Wildcard:** the primary domain starts with `*.`. - **Multi-domain:** the selected product is a UCC product, or the CSR or gateway SAN list carries DNS names beyond the primary domain (its `www.` variant, and a wildcard's bare apex, don't count). Those names are sent as `additionalDomains`, which makes CERTInext choose a UCC product. - - **Wildcard in the SANs only (the exception):** the CN is a plain name, such as `example.com`, and a SAN is a wildcard, such as `*.example.com`. On some accounts CERTInext can't resolve this request itself. It treats an order as wildcard only when `certificate.domain` starts with `*.`, so it picks a plain UCC product and rejects the wildcard with `EMS-1173 Invalid Additional Domain Names`. Sending the wildcard as the domain doesn't work either: CERTInext requires the domain to match the CSR CN (`EMS-1056`). For this case, the plugin reads the account's catalog once. If the catalog has exactly one active Wildcard UCC product for the variant (`productTypeID` `21` for DV, `22` for OV), the plugin sends that product's code as `X-Product-Code`. It keeps the CN as the domain and sends the wildcard in `additionalDomains`. If no single product matches, or the catalog can't be read, the plugin logs a warning and places the order without `X-Product-Code`, leaving the product to CERTInext. Catalogs on other CA backends (such as SSL.com) need not use these `productTypeID` values. If CERTInext then rejects the wildcard (`EMS-1173`), the error asks you to set `ProductCode` on the template, which also skips the lookup. EV has no wildcard product, so EV requests in this shape are rejected before any order is placed. -2. **Explicit `ProductCode` (or the deprecated `ProfileId` alias)** — the override. It is sent as-is in the `X-Product-Code` header, after template save-time validation confirms it exists in the live V2 catalog and matches the selected product. The match is checked only when the catalog entry has a documented SSL `productTypeID`; otherwise the code is accepted as given. Use it when your account holds several matching products (for example different CA profiles for the same variant) and you want to force one. With an override, the plugin reads the catalog once per enrollment to recognize UCC and wildcard products. When the catalog entry has a documented SSL `productTypeID` (`13`-`22`), a single-domain product rejects extra SANs. When it doesn't (the code isn't listed, the entry has no or an unfamiliar `productTypeID`, or the catalog can't be read), the plugin decides from the request the same way as without an override: extra DNS names make it multi-domain and go out in `additionalDomains`, and CERTInext rejects the code if it can't carry them. + - **Wildcard in the SANs only:** the CN is a plain name, such as `example.com`, and a SAN is a wildcard, such as `*.example.com`. The CN stays the domain (CERTInext requires the domain to match the CSR CN, `EMS-1056`), and the wildcard is sent in `additionalDomains`. EV has no wildcard product, so EV requests in this shape are rejected before any order is placed. +2. **Explicit `ProductCode` (or the deprecated `ProfileId` alias)** — the override. It is sent as-is in the `X-Product-Code` header, after template save-time validation confirms it exists in the live V2 catalog and matches the selected product. The match is checked only when the catalog entry has a documented SSL `productTypeID`; otherwise the code is accepted as given. CERTInext advises against sending it, so use it only when your account holds several matching products (for example different CA profiles for the same variant) and you want to force one. With an override, the plugin reads the catalog once per enrollment to recognize UCC and wildcard products. When the catalog entry has a documented SSL `productTypeID` (`13`-`22`), a single-domain product rejects extra SANs. When it doesn't (the code isn't listed, the entry has no or an unfamiliar `productTypeID`, or the catalog can't be read), the plugin decides from the request the same way as without an override: extra DNS names make it multi-domain and go out in `additionalDomains`, and CERTInext rejects the code if it can't carry them. This differs from V1, where `DefaultProductCode` only affects renewals (see [DefaultProductCode](#defaultproductcode)). From 5084e4a6bd71e632cad00baa04a9e4bcbf7797c6 Mon Sep 17 00:00:00 2001 From: spbsoluble <1661003+spbsoluble@users.noreply.github.com> Date: Tue, 17 Nov 2026 11:09:44 -0800 Subject: [PATCH 06/12] fix(v2): remove product-code pre-checks and let CERTInext reject a code it can't use V2 no longer checks a template ProductCode against the catalog: - Enrollment never reads the catalog. Wildcard/UCC is decided from the request for every SSL order (domain "*.", UCC template product, or extra DNS SANs going out in additionalDomains), with or without ProductCode. The single-domain SAN guard, which could only reject an explicit code the catalog listed as non-UCC, is gone. An explicit code is sent as given. - Template save (ValidateProductInfo) no longer looks the code up in the V2 catalog, for SSL or Private PKI. The ProductVariant, Private PKI variant and OV organization representative checks stay. - EV with a wildcard SAN is still rejected before ordering. V1 is unchanged: its template save still checks the code with GetProfilesAsync. Drops the now-unused WildcardProductTypeIds and PrivatePkiProductTypeId constants. --- CERTInext.Tests/CERTInextCAPluginV2Tests.cs | 156 ++-------- .../V2PrivatePkiEnrollmentTests.cs | 35 +-- .../V2ProductCodeResolutionTests.cs | 132 ++------ .../V2ProductVariantDerivationTests.cs | 2 +- CERTInext.Tests/V2UccEnrollmentTests.cs | 166 +++------- CERTInext.Tests/V2WildcardEnrollmentTests.cs | 89 ++---- CERTInext/CERTInextCAPlugin.cs | 288 ++---------------- CERTInext/Constants.cs | 28 +- CHANGELOG.md | 4 +- docsource/architecture.md | 18 +- docsource/configuration.md | 4 +- docsource/migration-v1-to-v2.md | 2 +- 12 files changed, 182 insertions(+), 742 deletions(-) diff --git a/CERTInext.Tests/CERTInextCAPluginV2Tests.cs b/CERTInext.Tests/CERTInextCAPluginV2Tests.cs index 9bc6205..2a9d3e2 100644 --- a/CERTInext.Tests/CERTInextCAPluginV2Tests.cs +++ b/CERTInext.Tests/CERTInextCAPluginV2Tests.cs @@ -1594,150 +1594,34 @@ private static Dictionary BuildV2ConnectionInfo(string apiUrl, s ProductParameters = new Dictionary { ["ProductCode"] = productCode } }; - [Fact] - public async Task ValidateProductInfo_V2_Succeeds_WhenProductCodeInCatalog() - { - using var server = WireMockServer.Start(); - StubV2TokenAndAuthMe(server); - server - .Given(Request.Create().WithPath("/api/certinext/v2/catalog/products").UsingGet()) - .RespondWith(Response.Create() - .WithStatusCode(200) - .WithHeader("Content-Type", "application/json") - .WithBody(MockCertificateData.GetCatalogProductsV2NestedJson())); - - var plugin = BuildV2Plugin(NewMock().Object); - var connInfo = BuildV2ConnectionInfo(server.Urls[0]); - var productInfo = BuildProductInfo(MockCertificateData.ProfileIdTls); - - Func act = () => plugin.ValidateProductInfo(productInfo, connInfo); - - await act.Should().NotThrowAsync(); - - // In V2 mode this must go through the V2 catalog, - // never the V1-only GetProductDetails endpoint. - server.LogEntries.Should().NotContain(e => e.RequestMessage.Path == "/GetProductDetails"); - server.LogEntries.Should().Contain(e => e.RequestMessage.Path == "/api/certinext/v2/catalog/products"); - } - - [Fact] - public async Task ValidateProductInfo_V2_Throws_WhenProductCodeNotInCatalog() - { - using var server = WireMockServer.Start(); - StubV2TokenAndAuthMe(server); - server - .Given(Request.Create().WithPath("/api/certinext/v2/catalog/products").UsingGet()) - .RespondWith(Response.Create() - .WithStatusCode(200) - .WithHeader("Content-Type", "application/json") - .WithBody(MockCertificateData.GetCatalogProductsV2NestedJson())); - - var plugin = BuildV2Plugin(NewMock().Object); - var connInfo = BuildV2ConnectionInfo(server.Urls[0]); - var productInfo = BuildProductInfo("999999"); - - Func act = () => plugin.ValidateProductInfo(productInfo, connInfo); - - await act.Should().ThrowAsync() - .WithMessage("*not found*"); - } - - [Fact] - public async Task ValidateProductInfo_V2_Throws_WhenCatalogEmpty() - { - using var server = WireMockServer.Start(); - StubV2TokenAndAuthMe(server); - server - .Given(Request.Create().WithPath("/api/certinext/v2/catalog/products").UsingGet()) - .RespondWith(Response.Create() - .WithStatusCode(200) - .WithHeader("Content-Type", "application/json") - .WithBody(MockCertificateData.GetCatalogProductsV2EmptyJson())); - - var plugin = BuildV2Plugin(NewMock().Object); - var connInfo = BuildV2ConnectionInfo(server.Urls[0]); - var productInfo = BuildProductInfo(MockCertificateData.ProfileIdTls); - - Func act = () => plugin.ValidateProductInfo(productInfo, connInfo); - - // No soft-accept on an empty/unusable catalog — must match V1's strict behaviour. - await act.Should().ThrowAsync() - .WithMessage("*not found*"); - } - - [Fact] - public async Task ValidateProductInfo_V2_Throws_WhenCatalogReturnsError() - { - using var server = WireMockServer.Start(); - StubV2TokenAndAuthMe(server); - server - .Given(Request.Create().WithPath("/api/certinext/v2/catalog/products").UsingGet()) - .RespondWith(Response.Create() - .WithStatusCode(500) - .WithHeader("Content-Type", "application/json") - .WithBody("{\"secretApiKeyLeak\":\"should-not-appear-in-message\"}")); - - var plugin = BuildV2Plugin(NewMock().Object); - var connInfo = BuildV2ConnectionInfo(server.Urls[0]); - var productInfo = BuildProductInfo(MockCertificateData.ProfileIdTls); - - Func act = () => plugin.ValidateProductInfo(productInfo, connInfo); - - var ex = await act.Should().ThrowAsync() - .WithMessage("*Unable to validate*"); - ex.Which.Message.Should().NotContain("secretApiKeyLeak"); - } - // --------------------------------------------------------------------------- - // productTypeID correctness check — catches a code that exists in the - // catalog but means a different product than the one selected, for both the - // explicit-override case and the no-override/fallback case. ValidateProductInfo - // must reject these, not just check catalog-existence. + // Explicit ProductCode on a V2 template: no product-code pre-check. The code is sent as given at + // enroll time and CERTInext rejects one it can't use, so template save never reads the catalog, + // whatever the catalog would have said. // --------------------------------------------------------------------------- - [Fact] - public async Task ValidateProductInfo_V2_Throws_WhenProductCodeExistsButProductTypeIdMismatchesSelectedProduct() + public static IEnumerable CatalogResponsesForExplicitCode() => new[] { - // Template selects "OV SSL" (expects productTypeID "16") but overrides ProductCode to - // "842", which the live catalog (stubbed here) resolves to productTypeID "13" = DV - // SSL. The code exists — a pure existence check would pass this — but it means a - // different product than the one selected. - using var server = WireMockServer.Start(); - StubV2TokenAndAuthMe(server); - server - .Given(Request.Create().WithPath("/api/certinext/v2/catalog/products").UsingGet()) - .RespondWith(Response.Create() - .WithStatusCode(200) - .WithHeader("Content-Type", "application/json") - .WithBody(@"[{""productCode"":""842"",""productName"":""DV SSL Certificate"",""productTypeID"":""13""}]")); - - var plugin = BuildV2Plugin(NewMock().Object); - var connInfo = BuildV2ConnectionInfo(server.Urls[0]); - var productInfo = new EnrollmentProductInfo - { - ProductID = Constants.Products.OvSsl, - ProductParameters = new Dictionary { ["ProductCode"] = "842" } - }; - - Func act = () => plugin.ValidateProductInfo(productInfo, connInfo); - - await act.Should().ThrowAsync() - .WithMessage("*does not correspond to the selected product*"); - } + // label, product ID, code, catalog status, catalog body + new object[] { "code in catalog", "DV SSL", MockCertificateData.ProfileIdTls, 200, MockCertificateData.GetCatalogProductsV2NestedJson() }, + new object[] { "code not in catalog", "DV SSL", "999999", 200, MockCertificateData.GetCatalogProductsV2NestedJson() }, + new object[] { "empty catalog", "DV SSL", MockCertificateData.ProfileIdTls, 200, MockCertificateData.GetCatalogProductsV2EmptyJson() }, + new object[] { "catalog error", "DV SSL", MockCertificateData.ProfileIdTls, 500, "{\"error\":\"boom\"}" }, + new object[] { "type mismatch", "OV SSL", "842", 200, @"[{""productCode"":""842"",""productTypeID"":""13""}]" }, + new object[] { "undocumented type", "DV SSL Wildcard Multi-Domain (UCC)", "1015", 200, @"[{""productCode"":""1015""}]" }, + }; - // A catalog on another CA backend (SSL.com) whose entry has no documented SSL productTypeID: - // the code exists, so it is accepted as given rather than rejected as a mismatch. [Theory] - [InlineData(@"[{""productCode"":""1015"",""productName"":""SSL.com DV Wildcard UCC""}]")] - [InlineData(@"[{""productCode"":""1015"",""productName"":""SSL.com DV Wildcard UCC"",""productTypeID"":""101""}]")] - public async Task ValidateProductInfo_V2_Passes_WhenProductCodeExistsWithUndocumentedProductTypeId(string catalogBody) + [MemberData(nameof(CatalogResponsesForExplicitCode))] + public async Task ValidateProductInfo_V2_ExplicitProductCode_Passes_WithoutAnyCatalogCall( + string label, string productId, string productCode, int catalogStatus, string catalogBody) { using var server = WireMockServer.Start(); StubV2TokenAndAuthMe(server); server .Given(Request.Create().WithPath("/api/certinext/v2/catalog/products").UsingGet()) .RespondWith(Response.Create() - .WithStatusCode(200) + .WithStatusCode(catalogStatus) .WithHeader("Content-Type", "application/json") .WithBody(catalogBody)); @@ -1745,13 +1629,15 @@ public async Task ValidateProductInfo_V2_Passes_WhenProductCodeExistsWithUndocum var connInfo = BuildV2ConnectionInfo(server.Urls[0]); var productInfo = new EnrollmentProductInfo { - ProductID = Constants.Products.DvSslWildcardUcc, - ProductParameters = new Dictionary { ["ProductCode"] = "1015" } + ProductID = productId, + ProductParameters = new Dictionary { ["ProductCode"] = productCode } }; Func act = () => plugin.ValidateProductInfo(productInfo, connInfo); - await act.Should().NotThrowAsync(); + await act.Should().NotThrowAsync(label); + server.LogEntries.Should().NotContain(e => e.RequestMessage.Path == "/api/certinext/v2/catalog/products", label); + server.LogEntries.Should().NotContain(e => e.RequestMessage.Path == "/GetProductDetails", label); } // --------------------------------------------------------------------------- diff --git a/CERTInext.Tests/V2PrivatePkiEnrollmentTests.cs b/CERTInext.Tests/V2PrivatePkiEnrollmentTests.cs index 34bbf7b..6604b05 100644 --- a/CERTInext.Tests/V2PrivatePkiEnrollmentTests.cs +++ b/CERTInext.Tests/V2PrivatePkiEnrollmentTests.cs @@ -535,7 +535,7 @@ public async Task ValidateProductInfo_V2_PrivatePki_Succeeds_WhenExplicitCodeIsA // product" would be thrown and no private-pki template could ever be saved. using var server = WireMockServer.Start(); StubToken(server); - StubCatalog(server, "149", Constants.ApiV2.PrivatePkiProductTypeId); + StubCatalog(server, "149", "39"); Func act = () => BuildV2Plugin(NewMock().Object) .ValidateProductInfo(MakePrivatePkiProductInfo(), V2ConnectionInfo(server.Urls[0])); @@ -543,30 +543,23 @@ public async Task ValidateProductInfo_V2_PrivatePki_Succeeds_WhenExplicitCodeIsA await act.Should().NotThrowAsync(); } - [Fact] - public async Task ValidateProductInfo_V2_PrivatePki_Throws_WhenExplicitCodeIsNotAPrivatePkiProduct() - { - using var server = WireMockServer.Start(); - StubToken(server); - StubCatalog(server, "842", "13"); // DV SSL - - Func act = () => BuildV2Plugin(NewMock().Object) - .ValidateProductInfo(MakePrivatePkiProductInfo(productCode: "842"), V2ConnectionInfo(server.Urls[0])); - - await act.Should().ThrowAsync().WithMessage("*not a Private PKI product*"); - } - - [Fact] - public async Task ValidateProductInfo_V2_PrivatePki_Throws_WhenCodeNotInCatalog() + // No product-code pre-check: a Private PKI ProductCode is sent as given, and CERTInext rejects one + // that isn't a Private PKI product or isn't on the account. Template save doesn't read the catalog. + [Theory] + [InlineData("842", "842", "13")] // an SSL product + [InlineData("149", "100", "39")] // not in the catalog + public async Task ValidateProductInfo_V2_PrivatePki_ExplicitCode_PassesWithoutCatalogCall( + string productCode, string catalogCode, string catalogTypeId) { using var server = WireMockServer.Start(); StubToken(server); - StubCatalog(server, "100", Constants.ApiV2.PrivatePkiProductTypeId); + StubCatalog(server, catalogCode, catalogTypeId); Func act = () => BuildV2Plugin(NewMock().Object) - .ValidateProductInfo(MakePrivatePkiProductInfo(productCode: "149"), V2ConnectionInfo(server.Urls[0])); + .ValidateProductInfo(MakePrivatePkiProductInfo(productCode: productCode), V2ConnectionInfo(server.Urls[0])); - await act.Should().ThrowAsync().WithMessage("*not found*"); + await act.Should().NotThrowAsync(); + server.LogEntries.Should().NotContain(e => e.RequestMessage.Path == "/api/certinext/v2/catalog/products"); } [Theory] @@ -577,7 +570,7 @@ public async Task ValidateProductInfo_V2_PrivatePki_RejectsBadTemplateParams_Bef { using var server = WireMockServer.Start(); StubToken(server); - StubCatalog(server, "149", Constants.ApiV2.PrivatePkiProductTypeId); + StubCatalog(server, "149", "39"); Func act = () => BuildV2Plugin(NewMock().Object) .ValidateProductInfo(MakePrivatePkiProductInfo(variant: variant, productCode: productCode), @@ -592,7 +585,7 @@ public async Task ValidateProductInfo_V2_PrivatePki_NoProductCode_PassesWithoutC { using var server = WireMockServer.Start(); StubToken(server); - StubCatalog(server, "149", Constants.ApiV2.PrivatePkiProductTypeId); + StubCatalog(server, "149", "39"); Func act = () => BuildV2Plugin(NewMock().Object) .ValidateProductInfo(MakePrivatePkiProductInfo(productCode: null), V2ConnectionInfo(server.Urls[0])); diff --git a/CERTInext.Tests/V2ProductCodeResolutionTests.cs b/CERTInext.Tests/V2ProductCodeResolutionTests.cs index ab03a30..b23d6e3 100644 --- a/CERTInext.Tests/V2ProductCodeResolutionTests.cs +++ b/CERTInext.Tests/V2ProductCodeResolutionTests.cs @@ -130,43 +130,39 @@ public async Task NoExplicitProductCode_ConnectorDefaultProductCode_NoLongerPins mock.Verify(c => c.GetProductDetailsV2Async(It.IsAny()), Times.Never); } - [Fact] - public async Task ExplicitProductCode_IsStillSent_AndCatalogStillDecidesUcc() + // Explicit ProductCode: sent as given, with no product-code pre-check. The catalog is never read; + // UCC is decided from the request (extra DNS SANs go out in additionalDomains), and CERTInext + // rejects a code that can't carry them. + public static IEnumerable ExplicitCodeRequests() => new[] { - var (mock, cap) = NewSslMock(); - mock.Setup(c => c.GetProductDetailsV2Async(It.IsAny())) - .ReturnsAsync(new List - { - new ProductDetail { ProductCode = "844", ProductTypeId = "15", Active = true } // DV SSL UCC - }); - var plugin = new CERTInextCAPlugin(mock.Object, Config(defaultProductCode: "842")); - - // ProductId is a NON-UCC product; the explicit code's catalog entry is UCC, so the - // catalog (not the ProductId) decides and the extra SAN goes out as additionalDomains. - await EnrollAsync(plugin, ProductInfo(Constants.Products.DvSsl, productCode: "844"), - "example.com", "extra.example.com"); - - cap.ProductCode.Should().Be("844"); - cap.Request.Certificate.AdditionalDomains.Should().Equal("extra.example.com"); - mock.Verify(c => c.GetProductDetailsV2Async(It.IsAny()), Times.Once); - } + // label, ProductId, code, DNS SANs, expected additionalDomains + new object[] { "UCC code, extra SAN", Constants.Products.DvSslUcc, "844", + new[] { "example.com", "extra.example.com" }, new[] { "extra.example.com" } }, + new object[] { "single-domain code, extra SAN", Constants.Products.DvSsl, "842", + new[] { "example.com", "extra.example.com" }, new[] { "extra.example.com" } }, + new object[] { "Wildcard UCC code, wildcard SAN on apex CN", Constants.Products.DvSslWildcardUcc, "845", + new[] { "example.com", "*.example.com" }, new[] { "*.example.com" } }, + new object[] { "code from another CA backend, wildcard SAN", Constants.Products.DvSsl, "1015", + new[] { "example.com", "*.example.com" }, new[] { "*.example.com" } }, + new object[] { "single domain", Constants.Products.DvSsl, "1011", + new[] { "example.com" }, new string[0] }, + }; - [Fact] - public async Task ExplicitProductCode_NonUccCatalogEntry_StillRejectsExtraSans() + [Theory] + [MemberData(nameof(ExplicitCodeRequests))] + public async Task ExplicitProductCode_IsSentAsGiven_WithoutReadingTheCatalog( + string label, string productId, string productCode, string[] sans, string[] expectedAdditional) { var (mock, cap) = NewSslMock(); - mock.Setup(c => c.GetProductDetailsV2Async(It.IsAny())) - .ReturnsAsync(new List - { - new ProductDetail { ProductCode = "842", ProductTypeId = "13", Active = true } - }); var plugin = new CERTInextCAPlugin(mock.Object, Config()); - var result = await EnrollAsync(plugin, ProductInfo(Constants.Products.DvSsl, productCode: "842"), - "example.com", "extra.example.com"); + var result = await EnrollAsync(plugin, ProductInfo(productId, productCode: productCode), sans); - result.Status.Should().Be((int)EndEntityStatus.FAILED); - cap.Placed.Should().BeFalse(); + result.CARequestID.Should().Be(OrderId, label); + cap.ProductCode.Should().Be(productCode, label); + cap.Request.Certificate.Domain.Should().Be("example.com", label); + (cap.Request.Certificate.AdditionalDomains ?? new List()).Should().BeEquivalentTo(expectedAdditional, label); + mock.Verify(c => c.GetProductDetailsV2Async(It.IsAny()), Times.Never, label); } [Fact] @@ -259,80 +255,6 @@ public async Task NoExplicitProductCode_WildcardSanOnApexCn_WithAnotherName_Send mock.Verify(c => c.GetProductDetailsV2Async(It.IsAny()), Times.Never); } - [Fact] - public async Task ExplicitProductCode_WildcardUccCatalogEntry_WildcardSanOnApexCn_SendsTheTemplatesCode() - { - var (mock, cap) = NewSslMock(); - mock.Setup(c => c.GetProductDetailsV2Async(It.IsAny())) - .ReturnsAsync(new List - { - new ProductDetail { ProductCode = "845", ProductTypeId = "21", Active = true } // DV SSL Wildcard UCC - }); - var plugin = new CERTInextCAPlugin(mock.Object, Config()); - - await EnrollAsync(plugin, ProductInfo(Constants.Products.DvSslWildcardUcc, productCode: "845"), - "example.com", "*.example.com"); - - cap.ProductCode.Should().Be("845", "an explicit template ProductCode is sent as given"); - cap.Request.Certificate.AdditionalDomains.Should().Equal("*.example.com"); - } - - // Explicit ProductCode whose catalog entry doesn't carry a documented SSL productTypeID (code not - // listed, no type, an unfamiliar type, or no catalog): the request decides, so the wildcard SAN - // goes out in additionalDomains instead of being rejected as an extra SAN. - public static IEnumerable UnidentifiedExplicitCodeCatalogs() => new[] - { - new object[] { "not listed", new List { new ProductDetail { ProductCode = "842", ProductTypeId = "13", Active = true } } }, - new object[] { "no type id", new List { new ProductDetail { ProductCode = "1015", Active = true } } }, - new object[] { "unfamiliar type id", new List { new ProductDetail { ProductCode = "1015", ProductTypeId = "101", Active = true } } }, - }; - - [Theory] - [MemberData(nameof(UnidentifiedExplicitCodeCatalogs))] - public async Task ExplicitProductCode_UnidentifiedByCatalog_WildcardSanOnApexCn_DecidesFromTheRequest( - string label, List catalog) - { - var (mock, cap) = NewSslMock(); - mock.Setup(c => c.GetProductDetailsV2Async(It.IsAny())).ReturnsAsync(catalog); - var plugin = new CERTInextCAPlugin(mock.Object, Config()); - - var result = await EnrollAsync(plugin, ProductInfo(Constants.Products.DvSsl, productCode: "1015"), - "example.com", "*.example.com"); - - result.CARequestID.Should().Be(OrderId, label); - cap.ProductCode.Should().Be("1015", label); - cap.Request.Certificate.AdditionalDomains.Should().Equal("*.example.com"); - } - - [Fact] - public async Task ExplicitProductCode_CatalogUnavailable_ExtraSan_DecidesFromTheRequest() - { - var (mock, cap) = NewSslMock(); - mock.Setup(c => c.GetProductDetailsV2Async(It.IsAny())) - .ThrowsAsync(new Exception("catalog down")); - var plugin = new CERTInextCAPlugin(mock.Object, Config()); - - var result = await EnrollAsync(plugin, ProductInfo(Constants.Products.DvSsl, productCode: "844"), - "example.com", "extra.example.com"); - - result.CARequestID.Should().Be(OrderId); - cap.Request.Certificate.AdditionalDomains.Should().Equal("extra.example.com"); - } - - [Fact] - public async Task ExplicitProductCode_UnidentifiedByCatalog_SingleDomain_SendsNoAdditionalDomains() - { - var (mock, cap) = NewSslMock(); - mock.Setup(c => c.GetProductDetailsV2Async(It.IsAny())) - .ReturnsAsync(new List { new ProductDetail { ProductCode = "1011", Active = true } }); - var plugin = new CERTInextCAPlugin(mock.Object, Config()); - - await EnrollAsync(plugin, ProductInfo(Constants.Products.DvSsl, productCode: "1011"), "example.com"); - - cap.ProductCode.Should().Be("1011"); - (cap.Request.Certificate.AdditionalDomains ?? new List()).Should().BeEmpty(); - } - [Fact] public async Task NoExplicitProductCode_WildcardSanOnEv_FailsWithoutReadingTheCatalog() { @@ -370,8 +292,6 @@ public async Task OrderCreated_WithoutResolvedProductCodeInResponse_LogsNotRepor await EnrollAsync(plugin, ProductInfo(Constants.Products.DvSsl, productCode: "842"), "example.com"); - // (the explicit code path reads the catalog; it is not stubbed here, so the plugin logs a - // warning and decides UCC from the request's SANs) var lines = capture.Lines(LogLevel.Information, "V2 order placed"); lines.Should().ContainSingle(); lines[0].Should().Contain("ResolvedProductCode=(not reported)").And.Contain("XProductCodeSent=842"); diff --git a/CERTInext.Tests/V2ProductVariantDerivationTests.cs b/CERTInext.Tests/V2ProductVariantDerivationTests.cs index 70dc337..559368c 100644 --- a/CERTInext.Tests/V2ProductVariantDerivationTests.cs +++ b/CERTInext.Tests/V2ProductVariantDerivationTests.cs @@ -429,7 +429,7 @@ public async Task ValidateProductInfo_V2_PrivatePki_NotAffectedByThisSslCheck() // ValidatePrivatePkiEnrollmentParams instead, unaffected here. using var server = WireMockServer.Start(); StubToken(server); - StubCatalogServer(server, "149", Constants.ApiV2.PrivatePkiProductTypeId); + StubCatalogServer(server, "149", "39"); var productInfo = new EnrollmentProductInfo { diff --git a/CERTInext.Tests/V2UccEnrollmentTests.cs b/CERTInext.Tests/V2UccEnrollmentTests.cs index 6a7eaeb..fb7194b 100644 --- a/CERTInext.Tests/V2UccEnrollmentTests.cs +++ b/CERTInext.Tests/V2UccEnrollmentTests.cs @@ -170,75 +170,6 @@ public async Task Enroll_V2_UccProduct_PopulatesAdditionalDomainsFromGatewaySanD "(not the CSR) is the source for a UCC order's additional domains"); } - [Fact] - public async Task Enroll_V2_NonUccProduct_SanDictionaryCarriesExtras_StillFailsFastWithNoPlaceOrderCall() - { - // A CSR-only guard (looking at the CSR alone) would miss the case where the - // CSR carries only the primary domain but the SAN dictionary's extra - // domain silently vanishes — a non-UCC order never sends additionalDomains at all, so - // there is nowhere for it to go. The guard must consider the SAN dictionary too - // and reject, the same way it already rejects CSR-borne extras - // (Enroll_V2_NonUccProduct_CsrCarriesExtraSans_StillFailsFastWithNoPlaceOrderCall). - var mock = NewMock(); - StubCatalog(mock, "842", "13"); // DV SSL (non-UCC) - - var plugin = BuildV2Plugin(mock.Object); - - var result = await plugin.Enroll( - csr: GenerateCsrPem("example.com"), - subject: "CN=example.com", - san: new Dictionary - { - ["dns"] = new[] { "example.com", "san1.example.com" } - }, - productInfo: MakeV2ProductInfo("842"), - requestFormat: RequestFormat.PKCS10, - enrollmentType: EnrollmentType.New); - - result.Status.Should().Be((int)EndEntityStatus.FAILED); - result.StatusMessage.Should().Contain("1 SAN(s) beyond"); - result.StatusMessage.Should().Contain("single domain"); - - mock.Verify(c => c.PlaceOrderV2Async( - It.IsAny(), It.IsAny(), - It.IsAny(), It.IsAny()), Times.Never, - "a rejected non-UCC request must never reach order placement, whether the extra " + - "SAN came from the CSR or the SAN dictionary"); - } - - [Fact] - public async Task Enroll_V2_NonUccProduct_SanDictionaryHasOnlyPrimary_ButCsrCarriesExtraSan_StillFailsFastWithNoPlaceOrderCall() - { - // A non-null SAN dictionary that carries only the primary domain must not make the - // guard defer to the dictionary and skip the CSR. SubmitCsrV2Async sends the CSR to - // CERTInext verbatim regardless of what the SAN dictionary contains, so a - // CSR-embedded extra domain still reaches the CA even when the dictionary is - // single-domain — the guard must reject this exactly like the CSR-only case - // (Enroll_V2_NonUccProduct_CsrCarriesExtraSans_StillFailsFastWithNoPlaceOrderCall). - var mock = NewMock(); - StubCatalog(mock, "842", "13"); // DV SSL (non-UCC) - - var plugin = BuildV2Plugin(mock.Object); - - var result = await plugin.Enroll( - csr: GenerateCsrPem("example.com", "example.com", "other.example.com"), - subject: "CN=example.com", - san: new Dictionary { ["dns"] = new[] { "example.com" } }, - productInfo: MakeV2ProductInfo("842"), - requestFormat: RequestFormat.PKCS10, - enrollmentType: EnrollmentType.New); - - result.Status.Should().Be((int)EndEntityStatus.FAILED); - result.StatusMessage.Should().Contain("1 SAN(s) beyond"); - result.StatusMessage.Should().Contain("single domain"); - - mock.Verify(c => c.PlaceOrderV2Async( - It.IsAny(), It.IsAny(), - It.IsAny(), It.IsAny()), Times.Never, - "a non-null SAN dictionary carrying only the primary domain must not make the " + - "guard defer to it and miss a CSR-embedded extra SAN"); - } - [Fact] public async Task Enroll_V2_NonUccProduct_SanDictionaryHasOnlyPrimaryAndWwwVariant_Allowed() { @@ -363,84 +294,63 @@ public async Task Enroll_V2_UccProduct_CsrCarriesExtraSans_OrderIsPlacedWithSans req.Certificate.Domain.Should().Be("example.com"); req.Certificate.AdditionalDomains.Should().BeEquivalentTo( new[] { "extra1.example.com", "extra2.example.com" }, - "a UCC product's CSR-embedded extra SANs must flow into additionalDomains instead of " + - "tripping the single-domain guard"); + "a UCC product's CSR-embedded extra SANs must flow into additionalDomains, not be " + + "dropped"); } - [Fact] - public async Task Enroll_V2_NonUccProduct_CsrCarriesExtraSans_StillFailsFastWithNoPlaceOrderCall() + // No product-code pre-check: an explicit non-UCC code (842) with extra DNS SANs is placed, with the + // extras in additionalDomains from the request's SAN source, and the catalog isn't read. + // CERTInext rejects the code if it can't carry them. + public static IEnumerable ExplicitNonUccCodeWithExtras() => new[] { - // Counterpart to the UCC case above: a non-UCC product with the same multi-SAN CSR - // must keep the fail-fast behavior — FAILED, no order placed — even though - // the guard now necessarily runs after the (live) catalog lookup that determines - // UCC-ness, rather than before it. - var mock = NewMock(); - StubCatalog(mock, "842", "13"); // DV SSL (non-UCC) - - var plugin = BuildV2Plugin(mock.Object); - - var result = await plugin.Enroll( - csr: GenerateCsrPem("example.com", "example.com", "extra1.example.com", "extra2.example.com"), - subject: "CN=example.com", - san: null, - productInfo: MakeV2ProductInfo("842"), // non-UCC product code - requestFormat: RequestFormat.PKCS10, - enrollmentType: EnrollmentType.New); - - result.Status.Should().Be((int)EndEntityStatus.FAILED); - result.StatusMessage.Should().Contain("2 SAN(s) beyond"); - result.StatusMessage.Should().Contain("single domain"); - result.StatusMessage.Should().NotContain("The V2 API only supports single-domain certificates", - "the message must not claim V2 is single-domain-only in general — it's only true for non-UCC products"); - - mock.Verify(c => c.GetProductDetailsV2Async(It.IsAny()), Times.Once, - "UCC-ness can only be known after the catalog lookup, so the guard now runs after it"); - mock.Verify(c => c.PlaceOrderV2Async( - It.IsAny(), It.IsAny(), - It.IsAny(), It.IsAny()), Times.Never, - "a rejected non-UCC request must never reach order placement"); - } - - [Fact] - public async Task Enroll_V2_CatalogLookupFails_TreatedAsNonUcc_EnrollmentStillSucceeds() + // label, CSR SANs, SAN dictionary, expected additionalDomains + new object[] { "extras in CSR only", new[] { "example.com", "extra1.example.com", "extra2.example.com" }, null, + new[] { "extra1.example.com", "extra2.example.com" } }, + new object[] { "extras in SAN dictionary", new[] { "example.com" }, new[] { "example.com", "san1.example.com" }, + new[] { "san1.example.com" } }, + // The dictionary wins as the additionalDomains source when present (BuildSanList), so the CSR's + // extra reaches CERTInext only inside the CSR, the same as with no ProductCode. + new object[] { "dictionary has only the primary, CSR has an extra", new[] { "example.com", "other.example.com" }, + new[] { "example.com" }, new string[0] }, + }; + + [Theory] + [MemberData(nameof(ExplicitNonUccCodeWithExtras))] + public async Task Enroll_V2_ExplicitNonUccProductCode_ExtraSans_IsPlaced_WithoutReadingTheCatalog( + string label, string[] csrSans, string[] sanDictionary, string[] expectedAdditional) { var mock = NewMock(); - mock.Setup(c => c.GetProductDetailsV2Async(It.IsAny())) - .ThrowsAsync(new Exception("simulated transient catalog failure")); - V2CreateSslOrderRequest captured = null; + string sentCode = null; mock.Setup(c => c.PlaceOrderV2Async( It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) - .Callback((_, __, req, ___) => captured = req) - .ReturnsAsync(new V2CreateOrderResponse { OrderId = "ord_fallback_001", Status = "pending-dcv" }); - + .Callback((_, code, req, ___) => + { + sentCode = code; + captured = req; + }) + .ReturnsAsync(new V2CreateOrderResponse { OrderId = "ord_nonucc_010", Status = "pending-dcv" }); mock.Setup(c => c.SubmitCsrV2Async( - It.IsAny(), "ord_fallback_001", It.IsAny(), It.IsAny())) + It.IsAny(), "ord_nonucc_010", It.IsAny(), It.IsAny())) .Returns(Task.CompletedTask); - mock.Setup(c => c.TrackOrderV2Async(It.IsAny(), "ord_fallback_001", It.IsAny())) - .ReturnsAsync(new V2OrderStatusResponse { OrderId = "ord_fallback_001", Status = "pending-dcv" }); + mock.Setup(c => c.TrackOrderV2Async(It.IsAny(), "ord_nonucc_010", It.IsAny())) + .ReturnsAsync(new V2OrderStatusResponse { OrderId = "ord_nonucc_010", Status = "pending-dcv" }); var plugin = BuildV2Plugin(mock.Object); - // A catalog-lookup failure fails UCC-ness safe to false, so a non-empty - // SAN dictionary extra here would trip the dictionary-aware non-UCC reject - // guard instead of exercising this test's actual intent. Single-domain SAN data keeps - // the test focused on the catalog-lookup fallback it's named for. var result = await plugin.Enroll( - csr: GenerateCsrPem("example.com"), + csr: GenerateCsrPem("example.com", csrSans), subject: "CN=example.com", - san: new Dictionary { ["dns"] = new[] { "example.com" } }, - productInfo: MakeV2ProductInfo("844"), + san: sanDictionary == null ? null : new Dictionary { ["dns"] = sanDictionary }, + productInfo: MakeV2ProductInfo("842"), requestFormat: RequestFormat.PKCS10, enrollmentType: EnrollmentType.New); - result.CARequestID.Should().Be("ord_fallback_001", - "a catalog lookup failure must not block enrollment"); - captured.Should().NotBeNull(); - V2CreateSslOrderRequest req = captured!; - req.Certificate.AdditionalDomains.Should().BeNull( - "on a catalog failure, UCC-ness must fail safe to false rather than guess"); + result.CARequestID.Should().Be("ord_nonucc_010", label); + sentCode.Should().Be("842", label); + (captured!.Certificate.AdditionalDomains ?? new List()).Should().BeEquivalentTo(expectedAdditional, label); + mock.Verify(c => c.GetProductDetailsV2Async(It.IsAny()), Times.Never, label); } } } diff --git a/CERTInext.Tests/V2WildcardEnrollmentTests.cs b/CERTInext.Tests/V2WildcardEnrollmentTests.cs index f79117e..43c2f25 100644 --- a/CERTInext.Tests/V2WildcardEnrollmentTests.cs +++ b/CERTInext.Tests/V2WildcardEnrollmentTests.cs @@ -28,17 +28,10 @@ namespace Keyfactor.Extensions.CAPlugin.CERTInext.Tests { /// - /// Tests for the non-UCC V2 single-domain SAN guard's wildcard-apex exemption: - /// a wildcard product's CSR/SAN dictionary routinely also carries the bare apex alongside - /// the wildcard domain itself (e.g. "example.com" alongside "*.example.com"), and the guard - /// must not reject that apex as an "extra SAN" the way it would for any other non-UCC - /// product. Only the apex is exempt — any other extra SAN is still rejected, and non-wildcard - /// products are unaffected. - /// - /// NOTE: these tests only confirm the guard's accept/reject decision. What is actually sent - /// to the CA for the apex (whether additionalDomains needs it, or CERTInext handles it - /// automatically for a wildcard product) has not been confirmed against the live API — see - /// the comment in EnrollV2Async above the guard. + /// V2 wildcard enrollments: a wildcard CSR/SAN dictionary routinely also carries the bare apex + /// alongside the wildcard domain itself (e.g. "example.com" alongside "*.example.com"). The apex + /// isn't an "extra" name; any other DNS SAN goes out in additionalDomains. There is no + /// product-code pre-check: an explicit ProductCode is sent as given, without reading the catalog. /// public class V2WildcardEnrollmentTests { @@ -153,64 +146,44 @@ public async Task Enroll_V2_OvWildcard_ApexInSanDictionary_IsNotRejected() It.IsAny(), It.IsAny()), Times.Once); } - [Fact] - public async Task Enroll_V2_DvWildcard_NonApexExtraSan_StillRejected_WithoutSuggestingUcc() + // No product-code pre-check: an explicit ProductCode is sent as given and CERTInext rejects a + // product that can't carry the request. Extra SANs go out in additionalDomains (for a wildcard + // domain, its bare apex too), and the catalog isn't read. + [Theory] + [InlineData(Constants.Products.DvSslWildcard, "839", "*.example.com", new[] { "*.example.com", "example.com", "other.example.com" }, new[] { "example.com", "other.example.com" })] + [InlineData(Constants.Products.DvSsl, "842", "example.com", new[] { "example.com", "other.example.com" }, new[] { "other.example.com" })] + public async Task Enroll_V2_ExplicitProductCode_ExtraSan_IsPlaced_InAdditionalDomains_WithoutReadingTheCatalog( + string productId, string productCode, string domain, string[] sans, string[] expectedAdditional) { var mock = NewMock(); - StubCatalog(mock, "839", "14"); // DV SSL Wildcard - - var plugin = BuildV2Plugin(mock.Object); - - var result = await plugin.Enroll( - csr: MockCertificateData.FakeCsrPem, - subject: "CN=*.example.com", - san: new Dictionary + StubHappyOrderPlacement(mock); + V2CreateSslOrderRequest sent = null; + string sentCode = null; + mock.Setup(c => c.PlaceOrderV2Async( + It.IsAny(), It.IsAny(), + It.IsAny(), It.IsAny())) + .Callback((_, code, req, __) => { - // The apex is exempt, but an unrelated extra domain is not. - ["dns"] = new[] { "*.example.com", "example.com", "other.example.com" } - }, - productInfo: MakeWildcardProductInfo(Constants.Products.DvSslWildcard, "839", "*.example.com"), - requestFormat: RequestFormat.PKCS10, - enrollmentType: EnrollmentType.New); - - result.Status.Should().Be((int)EndEntityStatus.FAILED); - result.StatusMessage.Should().Contain("1 SAN(s) beyond"); - result.StatusMessage.Should().NotContain("UCC", - "a wildcard enrollment rejection must not suggest buying a UCC product"); - - mock.Verify(c => c.PlaceOrderV2Async( - It.IsAny(), It.IsAny(), - It.IsAny(), It.IsAny()), Times.Never); - } - - [Fact] - public async Task Enroll_V2_NonWildcardProduct_ApexNotExempt_StillRejected_AndSuggestsUcc() - { - // Sanity check that the exemption is wildcard-specific: a non-wildcard, non-UCC - // product's "extra" SAN set is unaffected by this fix, and its rejection message - // still offers the UCC suggestion (only wildcard products' wording changes). - var mock = NewMock(); - StubCatalog(mock, "842", "13"); // DV SSL (non-wildcard, non-UCC) + sentCode = code; + sent = req; + }) + .ReturnsAsync(new V2CreateOrderResponse { OrderId = "ord_wc_001", Status = "pending-dcv" }); var plugin = BuildV2Plugin(mock.Object); var result = await plugin.Enroll( csr: MockCertificateData.FakeCsrPem, - subject: "CN=example.com", - san: new Dictionary - { - ["dns"] = new[] { "example.com", "other.example.com" } - }, - productInfo: MakeWildcardProductInfo(Constants.Products.DvSsl, "842", "example.com"), + subject: $"CN={domain}", + san: new Dictionary { ["dns"] = sans }, + productInfo: MakeWildcardProductInfo(productId, productCode, domain), requestFormat: RequestFormat.PKCS10, enrollmentType: EnrollmentType.New); - result.Status.Should().Be((int)EndEntityStatus.FAILED); - result.StatusMessage.Should().Contain("UCC"); - - mock.Verify(c => c.PlaceOrderV2Async( - It.IsAny(), It.IsAny(), - It.IsAny(), It.IsAny()), Times.Never); + result.CARequestID.Should().Be("ord_wc_001"); + sentCode.Should().Be(productCode); + sent!.Certificate.Domain.Should().Be(domain); + sent.Certificate.AdditionalDomains.Should().BeEquivalentTo(expectedAdditional); + mock.Verify(c => c.GetProductDetailsV2Async(It.IsAny()), Times.Never); } } } diff --git a/CERTInext/CERTInextCAPlugin.cs b/CERTInext/CERTInextCAPlugin.cs index 99fc03a..02488b2 100644 --- a/CERTInext/CERTInextCAPlugin.cs +++ b/CERTInext/CERTInextCAPlugin.cs @@ -887,120 +887,25 @@ public async Task ValidateProductInfo(EnrollmentProductInfo productInfo, Diction "ProductID={ProductID}", params_.ProductId); } - // V2 catalog validation mirrors ValidateCAConnectionInfo's UseV2Api branch: - // GetProfilesAsync/GetProductDetailsAsync are V1-only and 404 against a - // V2-shaped ApiUrl. There is no soft-accept difference between modes - // — an empty/unusable catalog is treated as "not found", same as V1. + // V2: the plugin doesn't check a ProductCode against the catalog. Without one, no + // X-Product-Code is sent and CERTInext's wrapper picks the product from the variant, + // wildcard shape and additional domains; with one, it's sent as given at enroll time + // and CERTInext rejects a code it can't use. The ProductVariant, private-pki and + // organization representative checks above already ran. V1 still checks the code + // against GetProfilesAsync (V1-only: it 404s against a V2-shaped ApiUrl). List availableIds; bool found; - if (v2WithoutProductCode) + if (useV2) { - // No explicit ProductCode: no X-Product-Code header is sent at enroll time and - // CERTInext's wrapper picks the product from the variant, wildcard shape and - // additional domains, so there is no code to look up in the catalog (and an - // ambiguous catalog match is no longer a template error). The ProductVariant - // and private-pki checks above already ran. _logger.LogInformation( - "Product/profile validation: no explicit ProductCode on the V2 template, so no catalog " + - "check is needed; CERTInext resolves the product at order time. ProductID={ProductID}", - params_.ProductId); + "Product/profile validation: V2 template ProductCode isn't checked against the catalog; " + + "CERTInext resolves or validates the product at order time. ProductCode={ProductCode}, " + + "ProductID={ProductID}", + v2WithoutProductCode ? "(none)" : profileId, params_.ProductId); availableIds = new List(); found = true; } - else if (useV2) - { - var products = await tempClient.GetProductDetailsV2Async(); - availableIds = products.Select(p => p.ProductCode).ToList(); - - if (isPrivatePki) - { - // The SSL ProductId -> productTypeID cross-check below would - // always reject a Private PKI code (GetProductIds only advertises SSL/TLS - // product names). Check the code against the spec's Private PKI - // productTypeID instead ("39" | Private PKI | Private PKI (8)). - var matchedProduct = products.FirstOrDefault(p => - string.Equals(p.ProductCode, profileId, StringComparison.OrdinalIgnoreCase)); - - if (matchedProduct == null) - { - var available = string.Join(", ", availableIds); - _logger.LogWarning( - "Product/profile validation failed — configured private-pki ProductCode '{ProfileId}' " + - "was not found in the CERTInext V2 catalog. AvailableCount={AvailableCount}", - profileId, availableIds.Count); - throw new AnyCAValidationException( - $"ProductCode '{profileId}' was not found in the CERTInext V2 catalog. " + - $"Available codes: {available}"); - } - - if (!string.Equals(matchedProduct.ProductTypeId, Constants.ApiV2.PrivatePkiProductTypeId, StringComparison.OrdinalIgnoreCase)) - { - _logger.LogWarning( - "Product/profile validation failed — configured ProductCode '{ProfileId}' exists in the " + - "CERTInext V2 catalog, but its productTypeID ('{ActualTypeId}') is not the Private PKI " + - "productTypeID ('{ExpectedTypeId}') while ProductFamily is 'private-pki'.", - profileId, matchedProduct.ProductTypeId, Constants.ApiV2.PrivatePkiProductTypeId); - throw new AnyCAValidationException( - $"ProductCode '{profileId}' exists in the CERTInext catalog, but it is not a Private PKI " + - "product, and the template's ProductFamily is 'private-pki'. Set ProductCode to a Private " + - "PKI product code from your account's catalog, or correct ProductFamily."); - } - - found = true; - } - else - { - // Explicit override (the no-ProductCode case was handled above): the code must exist in the catalog AND the matched - // catalog entry's productTypeID must actually correspond to the selected - // ProductId — not just "does this code exist as *some* product". A code - // can exist and still mean a different, wrong-assurance-level product than - // the one the administrator selected. - var matchedProduct = products.FirstOrDefault(p => - string.Equals(p.ProductCode, profileId, StringComparison.OrdinalIgnoreCase)); - - if (matchedProduct == null) - { - var available = string.Join(", ", availableIds); - _logger.LogWarning( - "Product/profile validation failed — configured ProductCode '{ProfileId}' was not " + - "found in the CERTInext V2 catalog. ProductID={ProductID}, AvailableCount={AvailableCount}", - profileId, params_.ProductId, availableIds.Count); - throw new AnyCAValidationException( - $"ProductCode '{profileId}' was not found in the CERTInext V2 catalog. " + - $"Available codes: {available}"); - } - - // Compared only when the catalog entry carries one of the documented SSL productTypeIDs: - // catalogs on other CA backends (SSL.com) need not, and the code is then taken as given. - string matchedTypeId = matchedProduct.ProductTypeId?.Trim(); - if (string.IsNullOrEmpty(matchedTypeId) || !Constants.Products.ProductTypeIdsV2.ContainsValue(matchedTypeId)) - { - _logger.LogInformation( - "Product/profile validation: ProductCode '{ProfileId}' is in the CERTInext V2 catalog " + - "with productTypeID '{TypeId}', which isn't a documented SSL product type; not checking " + - "it against the selected ProductID '{ProductID}'.", - profileId, matchedTypeId ?? "(none)", params_.ProductId); - } - else if (Constants.Products.ProductTypeIdsV2.TryGetValue(params_.ProductId ?? string.Empty, out string expectedTypeId) - && !string.Equals(matchedTypeId, expectedTypeId, StringComparison.OrdinalIgnoreCase)) - { - _logger.LogWarning( - "Product/profile validation failed — configured ProductCode '{ProfileId}' exists in " + - "the CERTInext V2 catalog, but its catalog productTypeID ('{ActualTypeId}') does not " + - "match the selected ProductID '{ProductID}' (expected productTypeID '{ExpectedTypeId}'). " + - "This template would order a different product than the one selected.", - profileId, matchedProduct.ProductTypeId, params_.ProductId, expectedTypeId); - throw new AnyCAValidationException( - $"ProductCode '{profileId}' exists in the CERTInext catalog, but it does not " + - $"correspond to the selected product '{params_.ProductId}'. Verify the ProductCode " + - "override is correct for this product, or remove the override and let CERTInext " + - "resolve the product from the order shape."); - } - - found = true; - } - } else { var profiles = await tempClient.GetProfilesAsync(); @@ -2283,74 +2188,34 @@ private async Task EnrollV2CoreAsync( // directly to send only the variant and leave X-Product-Code out, so the plugin never // adds it on its own, for any request shape. // - // UCC / wildcard detection decides whether extra DNS SANs are carried in - // additionalDomains (UCC) or rejected by the single-domain guard below: - // - Explicit override: the live catalog entry for the code is looked up and, when its - // productTypeID is one of the documented SSL types (13-22), that type decides (UCC / - // non-UCC wildcard). When it doesn't (catalog unreadable, code not listed, no or an - // unfamiliar productTypeID, as on catalogs of other CA backends such as SSL.com), the - // request shape decides, as with no override: extra DNS SANs make it UCC. The template - // author chose the code, and CERTInext rejects a code that can't carry those names. - // - No override: no catalog call at all. The wildcard shape is the domain itself - // (starts "*."), exactly what the wrapper keys on. UCC is the template's product - // type (ProductId -> productTypeID, as before) OR the request carrying DNS SANs - // beyond the primary domain (its www. variant and a wildcard's bare apex are not - // "extra"), which is what makes the wrapper pick a UCC product — so those extras go - // out in additionalDomains instead of failing the single-domain guard. That includes a - // wildcard SAN on a non-wildcard domain (CN = apex, SAN = *.apex). + // The plugin doesn't check a ProductCode against the catalog: an explicit code is sent + // as given, and CERTInext rejects one that can't carry the request. Wildcard and UCC + // are decided from the request itself, the same way the wrapper does: + // - Wildcard: the domain starts "*.". + // - UCC: the template's product type (ProductId -> productTypeID) is UCC, OR the + // request carries DNS SANs beyond the primary domain (its www. variant and a + // wildcard's bare apex are not "extra"). Those extras go out in additionalDomains, + // including a wildcard SAN on a non-wildcard domain (CN = apex, SAN = *.apex). + // + // FindExtraDnsSans takes the UNION of the CSR's own SANs and the SAN dictionary: the + // create call sends the CSR to CERTInext verbatim, so a CSR-embedded extra domain + // reaches the CA even when Command also supplied a (single-domain) SAN dictionary. // // Private PKI: ProductCode is likewise optional (the wrapper resolves it from - // `variant`); the catalog is never fetched because its only use on this path — SSL UCC - // detection — does not apply. + // `variant`), and its SANs go in additionalHosts, so none of this applies. string productCode = ep.HasExplicitProductCode ? ep.ProductCode : null; bool isUccProduct = false; - bool isWildcardProduct = false; - if (!isPrivatePki && ep.HasExplicitProductCode) - { - List catalog = null; - try - { - catalog = await _client.GetProductDetailsV2Async(); - } - catch (Exception catalogEx) - { - _logger.LogWarning(catalogEx, - "EnrollV2Async: could not fetch the live V2 product catalog to detect UCC/wildcard for the " + - "explicit ProductCode; deciding from the request's SANs. ProductId={ProductId}", ep.ProductId); - } - - var matchedProduct = catalog?.FirstOrDefault(p => - string.Equals(p.ProductCode, ep.ProductCode, StringComparison.OrdinalIgnoreCase)); - string matchedTypeId = matchedProduct?.ProductTypeId?.Trim(); - if (!string.IsNullOrEmpty(matchedTypeId) - && Constants.Products.ProductTypeIdsV2.ContainsValue(matchedTypeId)) - { - isUccProduct = Constants.ApiV2.UccProductTypeIds.Contains(matchedTypeId); - isWildcardProduct = Constants.ApiV2.WildcardProductTypeIds.Contains(matchedTypeId); - } - else - { - isWildcardProduct = domain.StartsWith("*.", StringComparison.Ordinal); - isUccProduct = FindExtraDnsSans(csr, san, domain, isWildcardProduct).Count > 0; - _logger.LogInformation( - "EnrollV2Async: the catalog doesn't identify explicit ProductCode {ProductCode} as a known SSL " + - "product type (productTypeID={TypeId}); deciding from the request instead. Wildcard={Wildcard}, " + - "Ucc={Ucc}", ep.ProductCode, matchedProduct == null ? "(not listed)" : matchedTypeId ?? "(none)", - isWildcardProduct, isUccProduct); - } - } - else if (!isPrivatePki) + if (!isPrivatePki) { - isWildcardProduct = domain.StartsWith("*.", StringComparison.Ordinal); + bool isWildcardProduct = domain.StartsWith("*.", StringComparison.Ordinal); bool templateIsUccType = Constants.Products.ProductTypeIdsV2.TryGetValue( ep.ProductId ?? string.Empty, out string templateTypeId) && Constants.ApiV2.UccProductTypeIds.Contains(templateTypeId); var extraDnsSans = FindExtraDnsSans(csr, san, domain, isWildcardProduct); isUccProduct = templateIsUccType || extraDnsSans.Count > 0; - // Wildcard only in the SANs (CN = the apex, SAN = *.apex): the wildcard goes out in - // additionalDomains like any other extra name, and CERTInext picks the product. EV has - // no wildcard product at all, so that fails before placing an order. + // EV has no wildcard product at all, so a wildcard SAN on an EV request fails before + // placing an order. if (!isWildcardProduct && string.Equals(sslProductVariant, Constants.ApiV2.ProductVariantEv, StringComparison.OrdinalIgnoreCase) && extraDnsSans.Any(s => s.StartsWith("*.", StringComparison.Ordinal))) @@ -2370,98 +2235,11 @@ private async Task EnrollV2CoreAsync( } _logger.LogInformation( - "EnrollV2Async: no explicit ProductCode on the template — no X-Product-Code header will be sent; " + - "CERTInext resolves the product from the variant, wildcard shape and additional domains. " + - "ProductId={ProductId}, Wildcard={Wildcard}, Ucc={Ucc} (TemplateUccType={TemplateUccType}, " + - "ExtraDnsSanCount={ExtraCount})", - ep.ProductId, isWildcardProduct, isUccProduct, templateIsUccType, extraDnsSans.Count); - } - - // Non-UCC V2 products support only a single domain plus autoSecureWww's www. - // variant; any other DNS SAN — from the CSR OR Command's SAN dictionary — would be - // silently dropped or cause a CA-side rejection, so fail fast with a - // clear message rather than letting the CA return an opaque error, or the extra - // names vanish with no order-side signal at all. UCC (multi-domain) products are - // exempt — their extra SANs are the expected input and are carried into - // additionalDomains below instead. This check necessarily runs after UCC detection - // above, not before it, but it still runs before PlaceOrderV2Async, so a rejected - // non-UCC request never places a CA order. It can only trigger for an explicit - // ProductCode whose catalog entry is not UCC: with no explicit code the wrapper picks - // the product from the request shape, so any extra DNS SAN makes the order UCC above - // (and goes out in additionalDomains) instead of being rejected here. - // - // Looking at the CSR alone misses the case where Command's SAN - // dictionary carries the extras and the CSR itself carries only the primary domain — - // a non-UCC order never sends additionalDomains at all, so those dictionary-only - // extras would have nowhere to go and would be dropped with no warning. - // - // This guard deliberately takes the UNION of the CSR's own SANs and the SAN - // dictionary — NOT CollectRequestedSanEntries'/BuildSanList's "fallback, not union" - // rule (dictionary wins when non-null; CSR consulted only when the dictionary is - // null). That rule exists to decide what additionalDomains/additionalHosts actually - // send to the CA, where the CSR's own subjectAltName extension is otherwise ignored. - // Here it is wrong: the create call sends the CSR to CERTInext verbatim regardless - // of what the SAN dictionary contains, so a CSR-embedded extra domain still reaches - // the CA even when Command also supplied a (single-domain) SAN dictionary. Deferring - // to the dictionary alone whenever it is non-null would let that CSR-embedded extra - // slip past this guard unrejected for any enrollment that also happens to pass a SAN - // dictionary. - // - // SSL-only: a private-pki order carries its SANs in additionalHosts, - // which the spec defines as a multi-entry "SAN list (DNS names or IPv4 / IPv6)" for - // every Private PKI variant, so the single-domain restriction does not apply. - // - // Wildcard apex exemption: a non-UCC wildcard product's `domain` is the literal - // wildcard value (e.g. "*.example.com"), and a wildcard CSR/SAN dictionary - // routinely also carries the bare apex ("example.com") alongside it — rejecting - // that apex as an "extra SAN" would make every ordinary wildcard CSR unenrollable - // via this guard. Exempt exactly the apex (the wildcard domain with its leading - // "*." stripped) for wildcard products (productTypeID 14/17, - // Constants.ApiV2.WildcardProductTypeIds) — any other extra SAN is still rejected. - // NOTE: this only widens what the guard *accepts*; it does not change - // what is sent to the CA for the apex — additionalDomains is still not populated - // for non-UCC products below. Whether CERTInext's V2 order create needs the apex - // added to additionalDomains (or handles it automatically for a wildcard product) - // is unverified and should be confirmed against a live order before relying on it. - if (!isPrivatePki && !isUccProduct) - { - var extraSans = FindExtraDnsSans(csr, san, domain, isWildcardProduct); - - if (extraSans.Count > 0) - { - _logger.LogWarning( - "EnrollV2Async rejected multi-SAN order on domain '{Domain}'. " + - "This product does not support additional domains via the V2 API " + - "(autoSecureWww covers www.); only UCC (multi-domain) products may carry " + - "extra SANs, whether requested via the CSR or Command's SAN dictionary. " + - "ExtraSans=[{ExtraSans}]", - LogSanitizer.Strip(domain), - LogSanitizer.Strip(string.Join(", ", extraSans))); - _logger.MethodExit(LogLevel.Debug); - // Wildcard products get their own wording: unlike a plain single-domain - // product, a wildcard product cannot be made to accept extra SANs by - // switching to a UCC product on this same domain, so the rejection must not - // suggest that. - string statusMessage = isWildcardProduct - ? $"V2 enrollment rejected: {extraSans.Count} SAN(s) beyond the primary wildcard " + - $"domain ('{domain}') and its www. variant were requested (via the CSR and/or " + - "Command's SAN dictionary). Only the primary wildcard domain and its bare apex " + - "are supported via the V2 API for this product. Resubmit with a CSR/SAN set " + - "carrying only those, and no other SANs." - : $"V2 enrollment rejected: {extraSans.Count} SAN(s) beyond the primary domain " + - $"('{domain}') and its www. variant were requested (via the CSR and/or Command's " + - "SAN dictionary). This product only supports a single domain via the V2 API " + - "(UCC/multi-domain products are the exception). Resubmit with a single-domain " + - "CSR and no additional SANs, or enroll against a UCC product if additional " + - "domains are required."; - return new EnrollmentResult - { - CARequestID = string.Empty, - Certificate = null, - Status = (int)EndEntityStatus.FAILED, - StatusMessage = statusMessage - }; - } + "EnrollV2Async: product decided by CERTInext from the variant, wildcard shape and additional " + + "domains. XProductCode={ProductCode}, ProductId={ProductId}, Wildcard={Wildcard}, Ucc={Ucc} " + + "(TemplateUccType={TemplateUccType}, ExtraDnsSanCount={ExtraCount})", + productCode ?? "(none)", ep.ProductId, isWildcardProduct, isUccProduct, templateIsUccType, + extraDnsSans.Count); } // For UCC products, additionalDomains is populated from the same SAN source the V1 diff --git a/CERTInext/Constants.cs b/CERTInext/Constants.cs index aa3a355..d37100b 100644 --- a/CERTInext/Constants.cs +++ b/CERTInext/Constants.cs @@ -208,9 +208,9 @@ public static class Products // NOTE: 15/18/20/21/22 match the real V2 sandbox catalog; the other five // (13/14/16/17/19) are spec-documented but have not been checked against it. // - // Used by EnrollV2Async/ValidateProductInfo to resolve/validate the real V2 product - // code from the live catalog when no explicit ProductCode override is configured. - // Never used for V1. + // Used by EnrollV2Async to tell whether the template's product is UCC (with UccProductTypeIds), + // and by Synchronize to name a synced order's product. It is never used to choose or check a + // product code. Never used for V1. public static readonly System.Collections.Generic.Dictionary ProductTypeIdsV2 = new System.Collections.Generic.Dictionary(System.StringComparer.OrdinalIgnoreCase) { @@ -599,11 +599,6 @@ public static class ApiV2 // The connector's EmailNotifications=0 maps to it and =1 maps to "all". public const string EmailNotificationsConsentOnly = "consent-only"; - // Catalog productTypeID for Private PKI products. Spec, Catalog -> List Products - // "productTypeID values": `"39"` | Private PKI | Private PKI (`8`). Also observed live - // on the sandbox catalog (product 149, "Sandbox emSign Intranet SSL 1 Year"). - public const string PrivatePkiProductTypeId = "39"; - // Document Signer create-body `subjectType` enum. Spec, "Document // Signer Certificates" field table: "`subjectType` | **Mandatory** // (`natural-person` / `legal-person` / `legal-entity`)". Not yet sourced by @@ -625,24 +620,15 @@ public static class ApiV2 // found to reuse for this one, so this remains a fixed default. public const string DefaultTechnicalContactDesignation = "Technical Contact"; - // UCC (multi-SAN) product family detection — from the live Catalog response's - // productTypeID field: 15=DV SSL UCC, 18=OV SSL UCC, 20=EV SSL UCC, - // 21=DV SSL Wildcard UCC, 22=OV SSL Wildcard UCC. + // UCC (multi-SAN) productTypeIDs (15=DV SSL UCC, 18=OV SSL UCC, 20=EV SSL UCC, + // 21=DV SSL Wildcard UCC, 22=OV SSL Wildcard UCC). Used only to tell whether the + // template's product name (via Products.ProductTypeIdsV2) is a UCC product; the catalog + // isn't read at enrollment. // Deliberately NOT derived from Constants.Products.DefaultProductCodes — that table's // numbering disagrees with the live/spec numbering. public static readonly System.Collections.Generic.HashSet UccProductTypeIds = new System.Collections.Generic.HashSet { "15", "18", "20", "21", "22" }; - // Non-UCC wildcard product family detection — from the live Catalog response's - // productTypeID field: 14=DV SSL Wildcard, 17=OV SSL Wildcard - // (Constants.Products.ProductTypeIdsV2). Deliberately excludes the UCC wildcard - // type IDs (21/22, in UccProductTypeIds above) — those are already exempt from - // the single-domain SAN guard by virtue of being UCC, and their additionalDomains - // handling is unrelated to the apex-SAN exemption this set is used for (the V2 - // single-domain enrollment guard in EnrollV2Async). - public static readonly System.Collections.Generic.HashSet WildcardProductTypeIds = - new System.Collections.Generic.HashSet { "14", "17" }; - // Orders report (Synchronize, V2 mode) — GET /api/certinext/v2/reports/orders. // Spring-style page envelope: content/page/size/totalPages/totalElements. // Paging is 1-based; size is clamped to 100 server-side; page=0 is treated as diff --git a/CHANGELOG.md b/CHANGELOG.md index e9fd3ec..2d12000 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## Features - feat(v2): Opt-in CERTInext V2 REST API via `UseV2Api` (default `false`), authenticated with OAuth2 `client_credentials`. - feat(v2): Enroll, renew, reissue, revoke, and synchronize SSL/TLS and Private PKI products, selected with the `ProductFamily` and `ProductVariant` template parameters. -- feat(v2): A template's `ProductCode` is validated against the V2 catalog when saved. +- feat(v2): A template's `ProductCode` is an optional override, sent as given in `X-Product-Code`. The plugin doesn't check it against the V2 catalog when the template is saved or at enrollment; CERTInext rejects a code it can't use. - feat(v2): Multi-domain (UCC) and wildcard SSL/TLS enrollment, with extra SANs sent as `additionalDomains`. - feat(v2): New OV template parameters `OrgRepresentativeName`, `OrgRepresentativeEmail`, `OrgRepresentativePhone`, `OrgRepresentativeDesignation` and `OrgRepresentativeEmployeeId` register a new Organization Representative on a V2 OV order (`useNewOrgRepresentative`). CERTInext's rules (OV only, a pre-vetted organization, name and email together, a 6-15 digit phone) are checked when the template is saved and before any CA call. The response's `organizationRepresentativeStatus` (`applied` or `pending-approval`) is logged, and the representative's details are never logged. - feat(v2): V2 OV and EV SSL/TLS orders check the organization's SSL.com validation first (status read, one refresh, and an optional submission). New settings `SslComSubmitOrganization` (default `false`; enabling it accepts SSL.com's subscriber agreement on the organization's behalf, audit-logged) and `SslComAdminEmail`. A not-validated organization or a failed SSL.com call only warns, and the order is placed anyway. @@ -22,7 +22,7 @@ ## Bug Fixes - fix(v2): A request whose CN is a plain name and whose SANs carry a wildcard (CN `example.com`, SAN `*.example.com`) keeps the CN as the domain and sends the wildcard in `additionalDomains`, with no `X-Product-Code` unless the template sets `ProductCode` (CERTInext's guidance is to send only the variant). An EV request in this shape is rejected before ordering, since EV has no wildcard product. -- fix(v2): With an explicit `ProductCode` whose catalog entry has no documented SSL `productTypeID` (not listed, no type, an unfamiliar type, or an unreadable catalog), extra SANs (including a wildcard SAN) are sent as `additionalDomains` instead of being rejected as a single-domain order. Template save-time validation likewise accepts such a code instead of rejecting it as a product mismatch. +- fix(v2): With an explicit `ProductCode`, extra SANs (including a wildcard SAN) are sent as `additionalDomains` instead of being rejected because the catalog lists the code as a single-domain product. Enrollment decides from the request, as it does without a `ProductCode`. - fix(v2): Flat catalog rows with a `productCode` key are read as available when they have no `active` field, and a numeric `productTypeID` no longer fails the catalog read. - fix(v2): A 422 `EMS-1165` from Download Certificate on an order CERTInext reports as `issued` is treated as "certificate not generated yet": the enrollment pickup keeps polling and returns pending, logging per attempt at Debug and one Information summary instead of a warning each time. `GetSingleRecord` and Synchronize log it quietly too (the sync summary gains `IssuedNotGeneratedYet`), and the log lines include CERTInext's `orderState` and `certificateState`. Other download errors still warn. - fix(v2): `EmailNotifications=0` (silent) is sent as `consent-only` on V2 order create, the quietest value in the spec's `consent-only | all` enum; the old `"0"` isn't a member of it. diff --git a/docsource/architecture.md b/docsource/architecture.md index 1f9d2a4..8a5835a 100644 --- a/docsource/architecture.md +++ b/docsource/architecture.md @@ -397,11 +397,8 @@ flowchart TD C -- No --> X1(["Enrollment rejected, no order placed"]) C -- Yes --> D{Private PKI?} D -- Yes --> G0 - D -- No --> E{"Explicit template ProductCode?"} - E -- Yes --> E1["Fetch the product catalog
to recognize UCC and wildcard products"] - E -- No --> E2["Detect UCC and wildcard from the request:
wildcard domain, UCC template product or extra DNS SANs"] - E1 --> F2{"Explicit non-UCC product with extra DNS SANs
in the CSR or SAN list?"} - E2 --> G0 + D -- No --> E2["Detect UCC and wildcard from the request:
wildcard domain, UCC template product or extra DNS SANs"] + E2 --> F2{"EV with a wildcard SAN?"} F2 -- Yes --> X3(["Failed result, no order placed"]) F2 -- No --> G0{"SSL/TLS with V2InlineCsr on?
(Private PKI never)"} G0 -- "No: two-call (V2InlineCsr false, or Private PKI)" --> G["Create the order without a CSR
(Idempotency-Key header, X-Product-Code only if the template sets ProductCode)"] @@ -440,11 +437,8 @@ flowchart TD Notes on the V2 flow: -- **Product code.** The spec makes `X-Product-Code` an optional override: CERTInext picks the catalog product itself from the variant, whether the domain is a wildcard (starts with `*.`), and whether `additionalDomains` is non-empty. So the plugin sends the header only when the template sets `ProductCode` (or the deprecated `ProfileId`), to choose between several matching catalog products. The connector's `DefaultProductCode` doesn't affect V2 orders. The create response's `resolvedProductCode` is logged at Information level. - - **With an explicit `ProductCode`,** the plugin fetches the live catalog once per enrollment, only to recognize multi-domain and wildcard products; if it can't be fetched, the order proceeds as single-domain, so a request with extra SANs is rejected rather than silently accepted. - - **Without one,** there is no catalog call. The order is a wildcard when the domain starts with `*.`. It is multi-domain when the selected product is a UCC product, or when the CSR or SAN list has DNS names beyond the primary domain (its `www.` variant, and a wildcard's bare apex, don't count); those names go out as `additionalDomains`, which is what makes CERTInext choose a UCC product. - - Private PKI never fetches the catalog. Its `ProductCode`, when set, was validated when the template was saved. +- **Product code.** The spec makes `X-Product-Code` an optional override: CERTInext picks the catalog product itself from the variant, whether the domain is a wildcard (starts with `*.`), and whether `additionalDomains` is non-empty. CERTInext advises sending only the variant, so the plugin sends the header only when the template sets `ProductCode` (or the deprecated `ProfileId`), and sends it as given. The connector's `DefaultProductCode` doesn't affect V2 orders. The create response's `resolvedProductCode` is logged at Information level. + - **No product-code pre-check.** Enrollment never reads the catalog, with or without `ProductCode`; CERTInext rejects a code it can't use. The order is a wildcard when the domain starts with `*.`. It is multi-domain when the selected product is a UCC product, or when the CSR or SAN list has DNS names beyond the primary domain (its `www.` variant, and a wildcard's bare apex, don't count); those names go out as `additionalDomains`, which is what makes CERTInext choose a UCC product. An EV request with a wildcard SAN is rejected before ordering, since EV has no wildcard product. - **SSL.com organization validation (OV/EV).** Just before the create call, an OV or EV SSL/TLS order reads the organization's SSL.com validation status, refreshes it once if the order's level isn't validated, and, only when `SslComSubmitOrganization` is on and the organization is ready, submits it (accepting SSL.com's subscriber agreement on its behalf, audit-logged). This step is advisory: any failure or not-validated result logs a warning and the order is placed anyway. See [SSL.com organization validation](configuration.md#sslcom-organization-validation). - **Multi-domain products.** DNS SANs other than the primary domain are sent as `additionalDomains`, and non-DNS SANs are left off the order with a warning. Private PKI sends DNS and IP SANs as `additionalHosts`. - **CSR delivery (`V2InlineCsr`).** By default (`V2InlineCsr = true`, SSL/TLS) the CSR is sent inline in the create body exactly as Command supplied it, and there is no Submit CSR step (a `PUT .../csr` after an inline CSR is rejected with HTTP 422). The create call then often holds about 20 seconds until the certificate is issued, and the order ID is known only once it returns. If that call fails with a 5xx or times out, the order may still exist and issue: the failure message says so, the plugin doesn't cancel the order, and the next sync imports it. Private PKI ignores the setting and always uses two calls, because CERTInext rejects an inline CSR on the Private PKI create (HTTP 422). With `V2InlineCsr = false` the plugin creates the order without a CSR and then submits it with `PUT .../csr`, cancelling the orphaned order once if that submit is rejected. That two-call flow fails for a domain the account has already validated: CERTInext reports the order `issued` at create, before any CSR, and then rejects the submit with HTTP 422 "Something went Wrong". A blank CSR is rejected before any CA call. @@ -555,9 +549,9 @@ The same https-or-loopback check runs again at gateway startup, so a connector s When an administrator saves a certificate template, the gateway asks the plugin to validate its product settings. On V1 the product code must be set (explicitly, or derived from the selected product) and appear in the CERTInext product list for the account. On V2: -- an explicit `ProductCode` is optional; if set, it must exist in the live catalog and match the selected product's type, and no catalog check runs without one; +- an explicit `ProductCode` is optional and isn't checked against the catalog (CERTInext rejects a code it can't use when the order is placed); - an SSL template's `ProductVariant` must agree with the selected product; -- a Private PKI template needs a Private PKI `ProductVariant`, and its `ProductCode`, if set, must be a Private PKI catalog product. +- a Private PKI template needs a Private PKI `ProductVariant`. Any failure is shown to the administrator with the candidate codes or the field to fix. diff --git a/docsource/configuration.md b/docsource/configuration.md index 34a5b9a..cb9e371 100644 --- a/docsource/configuration.md +++ b/docsource/configuration.md @@ -581,7 +581,7 @@ CERTInext advises sending only the variant and leaving `X-Product-Code` out, so - **Wildcard:** the primary domain starts with `*.`. - **Multi-domain:** the selected product is a UCC product, or the CSR or gateway SAN list carries DNS names beyond the primary domain (its `www.` variant, and a wildcard's bare apex, don't count). Those names are sent as `additionalDomains`, which makes CERTInext choose a UCC product. - **Wildcard in the SANs only:** the CN is a plain name, such as `example.com`, and a SAN is a wildcard, such as `*.example.com`. The CN stays the domain (CERTInext requires the domain to match the CSR CN, `EMS-1056`), and the wildcard is sent in `additionalDomains`. EV has no wildcard product, so EV requests in this shape are rejected before any order is placed. -2. **Explicit `ProductCode` (or the deprecated `ProfileId` alias)** — the override. It is sent as-is in the `X-Product-Code` header, after template save-time validation confirms it exists in the live V2 catalog and matches the selected product. The match is checked only when the catalog entry has a documented SSL `productTypeID`; otherwise the code is accepted as given. CERTInext advises against sending it, so use it only when your account holds several matching products (for example different CA profiles for the same variant) and you want to force one. With an override, the plugin reads the catalog once per enrollment to recognize UCC and wildcard products. When the catalog entry has a documented SSL `productTypeID` (`13`-`22`), a single-domain product rejects extra SANs. When it doesn't (the code isn't listed, the entry has no or an unfamiliar `productTypeID`, or the catalog can't be read), the plugin decides from the request the same way as without an override: extra DNS names make it multi-domain and go out in `additionalDomains`, and CERTInext rejects the code if it can't carry them. +2. **Explicit `ProductCode` (or the deprecated `ProfileId` alias)** — the override. It is sent as-is in the `X-Product-Code` header. CERTInext advises against sending it, so use it only when your account holds several matching products (for example different CA profiles for the same variant) and you want to force one. The plugin doesn't check the code against the catalog, either when the template is saved or at enrollment. It decides wildcard and multi-domain from the request the same way as without an override, and CERTInext rejects a code that doesn't exist or can't carry the request. This differs from V1, where `DefaultProductCode` only affects renewals (see [DefaultProductCode](#defaultproductcode)). @@ -589,7 +589,7 @@ This differs from V1, where `DefaultProductCode` only affects renewals (see [Def With `ProductFamily=private-pki`, the plugin places the order against CERTInext's Private PKI endpoint using the Private PKI request body, which differs from the SSL/TLS one: -- **Product code is optional.** CERTInext resolves the Private PKI product from `ProductVariant`. Set `ProductCode` to your account's Private PKI catalog code only to pick between several matching products; template validation then checks that it is a Private PKI product (`productTypeID` `39`). +- **Product code is optional.** CERTInext resolves the Private PKI product from `ProductVariant`. Set `ProductCode` to your account's Private PKI catalog code only to pick between several matching products. It isn't checked against the catalog; CERTInext rejects a code that isn't a Private PKI product on your account. - **Which `ProductID` to pick.** The plugin advertises SSL/TLS product names only, so the template still needs one from that list. It does not affect a `private-pki` order, which is built from `ProductVariant` (and `ProductCode`, if set), so any ProductID (for example `DV SSL`) works. - **Variant is required.** Set `ProductVariant` to `intranet-ssl` or `igtf-host`. - **Hostname.** The order's primary `hostname` comes from `DomainName`, or from the CSR's CN when `DomainName` isn't set. diff --git a/docsource/migration-v1-to-v2.md b/docsource/migration-v1-to-v2.md index 5295494..fdd94d6 100644 --- a/docsource/migration-v1-to-v2.md +++ b/docsource/migration-v1-to-v2.md @@ -15,7 +15,7 @@ and Synchronize — to V2. The two APIs cannot be mixed on a single connector. ### Before You Begin: Confirm V2 Will Work for Your Templates -- **Multi-domain (UCC) certificates are supported.** That covers DV UCC, DV Wildcard UCC, OV UCC, OV Wildcard UCC, and EV UCC. The plugin detects a UCC product from the live catalog's `productTypeID` and sends the extra SAN domains in the order's `additionalDomains` field. Per the V2 spec, a UCC order's SANs come from the order, not the CSR. +- **Multi-domain (UCC) certificates are supported.** That covers DV UCC, DV Wildcard UCC, OV UCC, OV Wildcard UCC, and EV UCC. The plugin treats a request as multi-domain when the selected product is a UCC product or the request carries extra DNS names, and sends those names in the order's `additionalDomains` field. Per the V2 spec, a UCC order's SANs come from the order, not the CSR. - **Only DNS SANs are sent.** `additionalDomains` takes DNS names only, so IP, email, and URI SANs are left off a UCC order and a warning is written to the gateway log. - **Non-UCC SSL products are checked up front.** A CSR or SAN list with DNS names beyond the primary domain and its `www.` variant is rejected before any order is placed. UCC products are exempt. - **DCV is not validated end to end in three cases.** These are per-SAN DCV on UCC orders, a domain that has never been validated, and wildcard DCV. The plugin runs the DNS-01 flow for each domain CERTInext reports as not yet validated, but test each UCC or wildcard template on the sandbox before relying on it in production. Keep it on a V1 connector if you need a validated path today. From a5dbbc7637979afc5d15293601be03b02dc2a10f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 17 Nov 2026 19:10:39 +0000 Subject: [PATCH 07/12] docs: auto-generate README and documentation [skip ci] --- README.md | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index b9fc8ff..ab5bbd6 100644 --- a/README.md +++ b/README.md @@ -634,7 +634,7 @@ CERTInext advises sending only the variant and leaving `X-Product-Code` out, so - **Wildcard:** the primary domain starts with `*.`. - **Multi-domain:** the selected product is a UCC product, or the CSR or gateway SAN list carries DNS names beyond the primary domain (its `www.` variant, and a wildcard's bare apex, don't count). Those names are sent as `additionalDomains`, which makes CERTInext choose a UCC product. - **Wildcard in the SANs only:** the CN is a plain name, such as `example.com`, and a SAN is a wildcard, such as `*.example.com`. The CN stays the domain (CERTInext requires the domain to match the CSR CN, `EMS-1056`), and the wildcard is sent in `additionalDomains`. EV has no wildcard product, so EV requests in this shape are rejected before any order is placed. -2. **Explicit `ProductCode` (or the deprecated `ProfileId` alias)** — the override. It is sent as-is in the `X-Product-Code` header, after template save-time validation confirms it exists in the live V2 catalog and matches the selected product. The match is checked only when the catalog entry has a documented SSL `productTypeID`; otherwise the code is accepted as given. CERTInext advises against sending it, so use it only when your account holds several matching products (for example different CA profiles for the same variant) and you want to force one. With an override, the plugin reads the catalog once per enrollment to recognize UCC and wildcard products. When the catalog entry has a documented SSL `productTypeID` (`13`-`22`), a single-domain product rejects extra SANs. When it doesn't (the code isn't listed, the entry has no or an unfamiliar `productTypeID`, or the catalog can't be read), the plugin decides from the request the same way as without an override: extra DNS names make it multi-domain and go out in `additionalDomains`, and CERTInext rejects the code if it can't carry them. +2. **Explicit `ProductCode` (or the deprecated `ProfileId` alias)** — the override. It is sent as-is in the `X-Product-Code` header. CERTInext advises against sending it, so use it only when your account holds several matching products (for example different CA profiles for the same variant) and you want to force one. The plugin doesn't check the code against the catalog, either when the template is saved or at enrollment. It decides wildcard and multi-domain from the request the same way as without an override, and CERTInext rejects a code that doesn't exist or can't carry the request. This differs from V1, where `DefaultProductCode` only affects renewals (see [DefaultProductCode](#defaultproductcode)). @@ -642,7 +642,7 @@ This differs from V1, where `DefaultProductCode` only affects renewals (see [Def With `ProductFamily=private-pki`, the plugin places the order against CERTInext's Private PKI endpoint using the Private PKI request body, which differs from the SSL/TLS one: -- **Product code is optional.** CERTInext resolves the Private PKI product from `ProductVariant`. Set `ProductCode` to your account's Private PKI catalog code only to pick between several matching products; template validation then checks that it is a Private PKI product (`productTypeID` `39`). +- **Product code is optional.** CERTInext resolves the Private PKI product from `ProductVariant`. Set `ProductCode` to your account's Private PKI catalog code only to pick between several matching products. It isn't checked against the catalog; CERTInext rejects a code that isn't a Private PKI product on your account. - **Which `ProductID` to pick.** The plugin advertises SSL/TLS product names only, so the template still needs one from that list. It does not affect a `private-pki` order, which is built from `ProductVariant` (and `ProductCode`, if set), so any ProductID (for example `DV SSL`) works. - **Variant is required.** Set `ProductVariant` to `intranet-ssl` or `igtf-host`. - **Hostname.** The order's primary `hostname` comes from `DomainName`, or from the CSR's CN when `DomainName` isn't set. @@ -756,7 +756,7 @@ and Synchronize — to V2. The two APIs cannot be mixed on a single connector. ### Before You Begin: Confirm V2 Will Work for Your Templates -- **Multi-domain (UCC) certificates are supported.** That covers DV UCC, DV Wildcard UCC, OV UCC, OV Wildcard UCC, and EV UCC. The plugin detects a UCC product from the live catalog's `productTypeID` and sends the extra SAN domains in the order's `additionalDomains` field. Per the V2 spec, a UCC order's SANs come from the order, not the CSR. +- **Multi-domain (UCC) certificates are supported.** That covers DV UCC, DV Wildcard UCC, OV UCC, OV Wildcard UCC, and EV UCC. The plugin treats a request as multi-domain when the selected product is a UCC product or the request carries extra DNS names, and sends those names in the order's `additionalDomains` field. Per the V2 spec, a UCC order's SANs come from the order, not the CSR. - **Only DNS SANs are sent.** `additionalDomains` takes DNS names only, so IP, email, and URI SANs are left off a UCC order and a warning is written to the gateway log. - **Non-UCC SSL products are checked up front.** A CSR or SAN list with DNS names beyond the primary domain and its `www.` variant is rejected before any order is placed. UCC products are exempt. - **DCV is not validated end to end in three cases.** These are per-SAN DCV on UCC orders, a domain that has never been validated, and wildcard DCV. The plugin runs the DNS-01 flow for each domain CERTInext reports as not yet validated, but test each UCC or wildcard template on the sandbox before relying on it in production. Keep it on a V1 connector if you need a validated path today. @@ -1372,11 +1372,8 @@ flowchart TD C -- No --> X1(["Enrollment rejected, no order placed"]) C -- Yes --> D{Private PKI?} D -- Yes --> G0 - D -- No --> E{"Explicit template ProductCode?"} - E -- Yes --> E1["Fetch the product catalog
to recognize UCC and wildcard products"] - E -- No --> E2["Detect UCC and wildcard from the request:
wildcard domain, UCC template product or extra DNS SANs"] - E1 --> F2{"Explicit non-UCC product with extra DNS SANs
in the CSR or SAN list?"} - E2 --> G0 + D -- No --> E2["Detect UCC and wildcard from the request:
wildcard domain, UCC template product or extra DNS SANs"] + E2 --> F2{"EV with a wildcard SAN?"} F2 -- Yes --> X3(["Failed result, no order placed"]) F2 -- No --> G0{"SSL/TLS with V2InlineCsr on?
(Private PKI never)"} G0 -- "No: two-call (V2InlineCsr false, or Private PKI)" --> G["Create the order without a CSR
(Idempotency-Key header, X-Product-Code only if the template sets ProductCode)"] @@ -1415,11 +1412,8 @@ flowchart TD Notes on the V2 flow: -- **Product code.** The spec makes `X-Product-Code` an optional override: CERTInext picks the catalog product itself from the variant, whether the domain is a wildcard (starts with `*.`), and whether `additionalDomains` is non-empty. So the plugin sends the header only when the template sets `ProductCode` (or the deprecated `ProfileId`), to choose between several matching catalog products. The connector's `DefaultProductCode` doesn't affect V2 orders. The create response's `resolvedProductCode` is logged at Information level. - - **With an explicit `ProductCode`,** the plugin fetches the live catalog once per enrollment, only to recognize multi-domain and wildcard products; if it can't be fetched, the order proceeds as single-domain, so a request with extra SANs is rejected rather than silently accepted. - - **Without one,** there is no catalog call. The order is a wildcard when the domain starts with `*.`. It is multi-domain when the selected product is a UCC product, or when the CSR or SAN list has DNS names beyond the primary domain (its `www.` variant, and a wildcard's bare apex, don't count); those names go out as `additionalDomains`, which is what makes CERTInext choose a UCC product. - - Private PKI never fetches the catalog. Its `ProductCode`, when set, was validated when the template was saved. +- **Product code.** The spec makes `X-Product-Code` an optional override: CERTInext picks the catalog product itself from the variant, whether the domain is a wildcard (starts with `*.`), and whether `additionalDomains` is non-empty. CERTInext advises sending only the variant, so the plugin sends the header only when the template sets `ProductCode` (or the deprecated `ProfileId`), and sends it as given. The connector's `DefaultProductCode` doesn't affect V2 orders. The create response's `resolvedProductCode` is logged at Information level. + - **No product-code pre-check.** Enrollment never reads the catalog, with or without `ProductCode`; CERTInext rejects a code it can't use. The order is a wildcard when the domain starts with `*.`. It is multi-domain when the selected product is a UCC product, or when the CSR or SAN list has DNS names beyond the primary domain (its `www.` variant, and a wildcard's bare apex, don't count); those names go out as `additionalDomains`, which is what makes CERTInext choose a UCC product. An EV request with a wildcard SAN is rejected before ordering, since EV has no wildcard product. - **SSL.com organization validation (OV/EV).** Just before the create call, an OV or EV SSL/TLS order reads the organization's SSL.com validation status, refreshes it once if the order's level isn't validated, and, only when `SslComSubmitOrganization` is on and the organization is ready, submits it (accepting SSL.com's subscriber agreement on its behalf, audit-logged). This step is advisory: any failure or not-validated result logs a warning and the order is placed anyway. See [SSL.com organization validation](configuration.md#sslcom-organization-validation). - **Multi-domain products.** DNS SANs other than the primary domain are sent as `additionalDomains`, and non-DNS SANs are left off the order with a warning. Private PKI sends DNS and IP SANs as `additionalHosts`. - **CSR delivery (`V2InlineCsr`).** By default (`V2InlineCsr = true`, SSL/TLS) the CSR is sent inline in the create body exactly as Command supplied it, and there is no Submit CSR step (a `PUT .../csr` after an inline CSR is rejected with HTTP 422). The create call then often holds about 20 seconds until the certificate is issued, and the order ID is known only once it returns. If that call fails with a 5xx or times out, the order may still exist and issue: the failure message says so, the plugin doesn't cancel the order, and the next sync imports it. Private PKI ignores the setting and always uses two calls, because CERTInext rejects an inline CSR on the Private PKI create (HTTP 422). With `V2InlineCsr = false` the plugin creates the order without a CSR and then submits it with `PUT .../csr`, cancelling the orphaned order once if that submit is rejected. That two-call flow fails for a domain the account has already validated: CERTInext reports the order `issued` at create, before any CSR, and then rejects the submit with HTTP 422 "Something went Wrong". A blank CSR is rejected before any CA call. @@ -1530,9 +1524,9 @@ The same https-or-loopback check runs again at gateway startup, so a connector s When an administrator saves a certificate template, the gateway asks the plugin to validate its product settings. On V1 the product code must be set (explicitly, or derived from the selected product) and appear in the CERTInext product list for the account. On V2: -- an explicit `ProductCode` is optional; if set, it must exist in the live catalog and match the selected product's type, and no catalog check runs without one; +- an explicit `ProductCode` is optional and isn't checked against the catalog (CERTInext rejects a code it can't use when the order is placed); - an SSL template's `ProductVariant` must agree with the selected product; -- a Private PKI template needs a Private PKI `ProductVariant`, and its `ProductCode`, if set, must be a Private PKI catalog product. +- a Private PKI template needs a Private PKI `ProductVariant`. Any failure is shown to the administrator with the candidate codes or the field to fix. From 5b778fcb414cbec4d065fe805474414e5750e771 Mon Sep 17 00:00:00 2001 From: spbsoluble <1661003+spbsoluble@users.noreply.github.com> Date: Tue, 17 Nov 2026 11:55:29 -0800 Subject: [PATCH 08/12] fix(v2): use Command's SAN list as the only source of extra names; address review findings SAN source: FindExtraDnsSans took the union of the CSR's SANs and the gateway's SAN dictionary, while additionalDomains came from the dictionary. A DNS name only in the CSR made the order multi-domain yet was left out of additionalDomains. Both now use CollectRequestedSanEntries: the dictionary, or the CSR only when the dictionary is null. That matches the other Keyfactor CA plugins that build a SAN list for their CA (DigiCert, Entrust, Vault, GCP CAS, GoDaddy, Sectigo, GlobalSign, HydrantID, SSLStore, CSC): dictionary only, CSR passed through, no union and no rejection. BuildSanList, which V1 also uses, is unchanged. Review findings: - Drop the EV wildcard pre-check (it covered only a wildcard SAN, not a wildcard domain); CERTInext decides. - Flat catalog rows: "active" is honored only as JSON true/false; a missing or null value is available, anything else isn't. The CHANGELOG no longer claims an Active fix (nothing reads it). - The UCC log line no longer says the plugin "resolved" a product. - Docs note that some accounts reject a wildcard-only-in-SANs request with EMS-1173, and that ProductCode is the way around it. - Catalog_ListsProductTypeIds comment: informational only. --- .../V2WildcardSanShapeTests.cs | 3 +- CERTInext.Tests/CERTInextClientV2Tests.cs | 8 +- .../V2ProductCodeResolutionTests.cs | 16 ++-- CERTInext.Tests/V2UccEnrollmentTests.cs | 76 ++++++++++++++++++- CERTInext/CERTInextCAPlugin.cs | 61 +++++---------- CERTInext/Client/CERTInextClient.cs | 11 ++- CHANGELOG.md | 5 +- docsource/architecture.md | 6 +- docsource/configuration.md | 5 +- docsource/migration-v1-to-v2.md | 2 +- 10 files changed, 128 insertions(+), 65 deletions(-) diff --git a/CERTInext.IntegrationTests/V2WildcardSanShapeTests.cs b/CERTInext.IntegrationTests/V2WildcardSanShapeTests.cs index be74f06..5e3dfba 100644 --- a/CERTInext.IntegrationTests/V2WildcardSanShapeTests.cs +++ b/CERTInext.IntegrationTests/V2WildcardSanShapeTests.cs @@ -108,7 +108,8 @@ private static string GenerateCsrPem(string commonName, IReadOnlyList dn /// /// Read-only: lists the account's live catalog entries with their productTypeID, so a run - /// shows the catalog codes and productTypeIDs an explicit template ProductCode can be checked against. + /// shows the account's product codes and productTypeIDs. Informational only: the plugin doesn't check a + /// template ProductCode against the catalog. /// [SkippableFact] public async Task Catalog_ListsProductTypeIds() diff --git a/CERTInext.Tests/CERTInextClientV2Tests.cs b/CERTInext.Tests/CERTInextClientV2Tests.cs index 2d59c60..3b59dd0 100644 --- a/CERTInext.Tests/CERTInextClientV2Tests.cs +++ b/CERTInext.Tests/CERTInextClientV2Tests.cs @@ -1627,7 +1627,10 @@ public async Task GetProductDetailsV2Async_FlatProductCodeRow_NoActiveField_Nume .WithHeader("Content-Type", "application/json") .WithBody(@"[ {""productCode"":""845"",""productName"":""DV SSL Certificate Wildcard UCC"",""productTypeID"":21}, - {""productCode"":""842"",""productName"":""DV SSL Certificate"",""productTypeID"":""13"",""active"":false} + {""productCode"":""842"",""productName"":""DV SSL Certificate"",""productTypeID"":""13"",""active"":false}, + {""productCode"":""843"",""productTypeID"":""14"",""active"":""false""}, + {""productCode"":""844"",""productTypeID"":""15"",""active"":0}, + {""productCode"":""846"",""productTypeID"":""16"",""active"":null} ]")); using var client = BuildV2Client(); @@ -1637,6 +1640,9 @@ public async Task GetProductDetailsV2Async_FlatProductCodeRow_NoActiveField_Nume "a row without an \"active\" field is available, and a numeric productTypeID reads as its string form"); products.Should().ContainSingle(p => p.ProductCode == "842" && !p.Active, "an explicit \"active\": false is kept"); + products.Should().ContainSingle(p => p.ProductCode == "843" && !p.Active, "a non-boolean \"false\" isn't trusted as active"); + products.Should().ContainSingle(p => p.ProductCode == "844" && !p.Active, "a numeric 0 isn't trusted as active"); + products.Should().ContainSingle(p => p.ProductCode == "846" && p.Active, "a null \"active\" counts as absent"); } [Fact] diff --git a/CERTInext.Tests/V2ProductCodeResolutionTests.cs b/CERTInext.Tests/V2ProductCodeResolutionTests.cs index b23d6e3..7d56359 100644 --- a/CERTInext.Tests/V2ProductCodeResolutionTests.cs +++ b/CERTInext.Tests/V2ProductCodeResolutionTests.cs @@ -255,17 +255,21 @@ public async Task NoExplicitProductCode_WildcardSanOnApexCn_WithAnotherName_Send mock.Verify(c => c.GetProductDetailsV2Async(It.IsAny()), Times.Never); } - [Fact] - public async Task NoExplicitProductCode_WildcardSanOnEv_FailsWithoutReadingTheCatalog() + // EV can't be a wildcard, but that's CERTInext's call to make: the request goes out like any other + // and CERTInext rejects it. No pre-check for either shape. + [Theory] + [InlineData("example.com", new[] { "example.com", "*.example.com" })] // wildcard SAN on an apex CN + [InlineData("*.example.com", new[] { "*.example.com" })] // wildcard primary domain + public async Task NoExplicitProductCode_EvWithWildcard_IsSentToCertinext(string domain, string[] sans) { var (mock, cap) = NewSslMock(); var plugin = new CERTInextCAPlugin(mock.Object, Config(organizationNumber: "ORG-1")); - var result = await EnrollAsync(plugin, ProductInfo(Constants.Products.EvSsl), "example.com", "*.example.com"); + var result = await EnrollAsync(plugin, ProductInfo(Constants.Products.EvSsl, domainName: domain), sans); - result.Status.Should().Be((int)EndEntityStatus.FAILED); - result.StatusMessage.Should().Contain("no wildcard product"); - cap.Placed.Should().BeFalse(); + result.CARequestID.Should().Be(OrderId); + cap.Request.ProductVariant.Should().Be("ev"); + cap.Request.Certificate.Domain.Should().Be(domain); mock.Verify(c => c.GetProductDetailsV2Async(It.IsAny()), Times.Never); } diff --git a/CERTInext.Tests/V2UccEnrollmentTests.cs b/CERTInext.Tests/V2UccEnrollmentTests.cs index fb7194b..c7b777b 100644 --- a/CERTInext.Tests/V2UccEnrollmentTests.cs +++ b/CERTInext.Tests/V2UccEnrollmentTests.cs @@ -308,8 +308,8 @@ public static IEnumerable ExplicitNonUccCodeWithExtras() => new[] new[] { "extra1.example.com", "extra2.example.com" } }, new object[] { "extras in SAN dictionary", new[] { "example.com" }, new[] { "example.com", "san1.example.com" }, new[] { "san1.example.com" } }, - // The dictionary wins as the additionalDomains source when present (BuildSanList), so the CSR's - // extra reaches CERTInext only inside the CSR, the same as with no ProductCode. + // Command's SAN dictionary is authoritative: a name only in the CSR is ignored (the CSR itself is + // still sent unchanged), as in the other Keyfactor CA plugins. new object[] { "dictionary has only the primary, CSR has an extra", new[] { "example.com", "other.example.com" }, new[] { "example.com" }, new string[0] }, }; @@ -352,5 +352,77 @@ public async Task Enroll_V2_ExplicitNonUccProductCode_ExtraSans_IsPlaced_Without (captured!.Certificate.AdditionalDomains ?? new List()).Should().BeEquivalentTo(expectedAdditional, label); mock.Verify(c => c.GetProductDetailsV2Async(It.IsAny()), Times.Never, label); } + + // Command's SAN dictionary is the SAN source for both the multi-domain decision and additionalDomains, + // as in the other Keyfactor CA plugins that build a SAN list (DigiCert, Entrust, Sectigo, GlobalSign, + // ...). The CSR is read only when the dictionary is null; the gateway passes an empty dictionary, + // not null, when Command sent no SANs. + public static IEnumerable SanSourceCases() => new[] + { + // label, CSR SANs, SAN dictionary DNS names (null = no dictionary), expected extra names + new object[] { "CSR-only extra, dictionary has the primary", new[] { "example.com", "other.example.com" }, + new[] { "example.com" }, new string[0] }, + new object[] { "CSR-only extra, empty dictionary", new[] { "example.com", "other.example.com" }, + new string[0], new string[0] }, + new object[] { "no dictionary: the CSR is used", new[] { "example.com", "other.example.com" }, + null, new[] { "other.example.com" } }, + new object[] { "extra only in the dictionary", new[] { "example.com" }, + new[] { "example.com", "san1.example.com" }, new[] { "san1.example.com" } }, + }; + + [Theory] + [MemberData(nameof(SanSourceCases))] + public void FindExtraDnsSans_UsesTheSanDictionary_CsrOnlyWhenThereIsNoDictionary( + string label, string[] csrSans, string[] dictionaryDns, string[] expected) + { + var san = dictionaryDns == null ? null : new Dictionary { ["dnsname"] = dictionaryDns }; + + var extras = CERTInextCAPlugin.FindExtraDnsSans( + GenerateCsrPem("example.com", csrSans), san, "example.com", isWildcard: false); + + extras.Should().BeEquivalentTo(expected, label); + } + + [Fact] + public async Task Enroll_V2_NoProductCode_CsrOnlyExtraSan_EmptyDictionary_IsASingleDomainOrder() + { + var mock = NewMock(); + V2CreateSslOrderRequest captured = null; + mock.Setup(c => c.PlaceOrderV2Async( + It.IsAny(), It.IsAny(), + It.IsAny(), It.IsAny())) + .Callback((_, __, req, ___) => captured = req) + .ReturnsAsync(new V2CreateOrderResponse { OrderId = "ord_csronly_001", Status = "pending-dcv" }); + mock.Setup(c => c.SubmitCsrV2Async( + It.IsAny(), "ord_csronly_001", It.IsAny(), It.IsAny())) + .Returns(Task.CompletedTask); + mock.Setup(c => c.TrackOrderV2Async(It.IsAny(), "ord_csronly_001", It.IsAny())) + .ReturnsAsync(new V2OrderStatusResponse { OrderId = "ord_csronly_001", Status = "pending-dcv" }); + + var plugin = BuildV2Plugin(mock.Object); + string csr = GenerateCsrPem("example.com", "example.com", "other.example.com"); + + var result = await plugin.Enroll( + csr: csr, + subject: "CN=example.com", + san: new Dictionary(), + productInfo: new EnrollmentProductInfo + { + ProductID = Constants.Products.DvSsl, + ProductParameters = new Dictionary + { + ["ProductFamily"] = "ssl", + ["DomainName"] = "example.com" + } + }, + requestFormat: RequestFormat.PKCS10, + enrollmentType: EnrollmentType.New); + + result.CARequestID.Should().Be("ord_csronly_001"); + captured!.Certificate.Domain.Should().Be("example.com"); + captured.Certificate.AdditionalDomains.Should().BeNull( + "a name only in the CSR doesn't make the order multi-domain"); + captured.Csr.Should().Be(csr, "the CSR is still sent to CERTInext unchanged"); + } } } diff --git a/CERTInext/CERTInextCAPlugin.cs b/CERTInext/CERTInextCAPlugin.cs index 02488b2..4c15046 100644 --- a/CERTInext/CERTInextCAPlugin.cs +++ b/CERTInext/CERTInextCAPlugin.cs @@ -1672,14 +1672,19 @@ internal static string ComposeV2Phone(string isdCode, string mobileNumber) } /// - /// DNS SANs on a V2 SSL request beyond what a single-domain order covers: the UNION of the - /// CSR's own subjectAltName entries and the gateway's SAN dictionary (deliberately not - /// BuildSanList's "dictionary wins, CSR only as fallback" rule — the create call - /// sends the CSR to CERTInext regardless of what the dictionary says, so a CSR-embedded - /// extra still reaches the CA), minus the primary , its - /// www. variant (autoSecureWww), and — for a wildcard order — the bare apex of the - /// wildcard (a wildcard CSR routinely carries it alongside *.example.com). - /// Lower-cased and de-duplicated. + /// DNS SANs on a V2 SSL request beyond what a single-domain order covers, from the same + /// source as additionalDomains (): the gateway's SAN + /// dictionary, or the CSR's own subjectAltName only when the dictionary is null (the + /// gateway passes an empty dictionary, not null, when Command sent no SANs). Minus the + /// primary , its www. variant (autoSecureWww), and, for a + /// wildcard order, the bare apex of the wildcard. Lower-cased and de-duplicated. + /// + /// Command's SAN list is authoritative: a DNS name only in the CSR doesn't make the order + /// multi-domain and isn't added to additionalDomains. The CSR still goes to CERTInext + /// unchanged. This matches the other Keyfactor CA plugins that build a SAN list for their CA + /// (DigiCert CertCentral and mPKI, Entrust, HashiCorp Vault, GCP CAS, GoDaddy, Sectigo, + /// GlobalSign, HydrantID, SSLStore, CSC: dictionary only, CSR passed through); none merges + /// in or rejects on CSR-only names. /// internal static List FindExtraDnsSans( string csr, Dictionary san, string domain, bool isWildcard) @@ -1689,15 +1694,7 @@ internal static List FindExtraDnsSans( ? StripWildcardPrefix(domain) : null; - var csrSanEntries = ExtractSanEntriesFromCsr(csr, out _); - // CollectRequestedSanEntries(san, csr: null, ...) yields exactly the SAN - // dictionary's own (MapSanType-normalized) entries: when san is non-null the - // CSR-fallback branch never runs, and when san is null there is nothing to - // collect (csr: null makes the fallback branch's own CSR read a no-op) — the - // real CSR is already covered by csrSanEntries above, so no double-count. - var dictSanEntries = CollectRequestedSanEntries(san, csr: null, out _, out _); - return csrSanEntries - .Concat(dictSanEntries) + return CollectRequestedSanEntries(san, csr, out _, out _) .Where(s => string.Equals(s.Type, "dns", StringComparison.OrdinalIgnoreCase)) .Select(s => s.Value?.ToLowerInvariant()) .Where(v => !string.IsNullOrWhiteSpace(v)) @@ -2197,9 +2194,9 @@ private async Task EnrollV2CoreAsync( // wildcard's bare apex are not "extra"). Those extras go out in additionalDomains, // including a wildcard SAN on a non-wildcard domain (CN = apex, SAN = *.apex). // - // FindExtraDnsSans takes the UNION of the CSR's own SANs and the SAN dictionary: the - // create call sends the CSR to CERTInext verbatim, so a CSR-embedded extra domain - // reaches the CA even when Command also supplied a (single-domain) SAN dictionary. + // FindExtraDnsSans and additionalDomains share one SAN source: Command's SAN dictionary + // (the CSR only when the dictionary is null). A name that is only in the CSR is ignored, + // as in the other Keyfactor CA plugins; the CSR itself is sent unchanged. // // Private PKI: ProductCode is likewise optional (the wrapper resolves it from // `variant`), and its SANs go in additionalHosts, so none of this applies. @@ -2214,26 +2211,6 @@ private async Task EnrollV2CoreAsync( var extraDnsSans = FindExtraDnsSans(csr, san, domain, isWildcardProduct); isUccProduct = templateIsUccType || extraDnsSans.Count > 0; - // EV has no wildcard product at all, so a wildcard SAN on an EV request fails before - // placing an order. - if (!isWildcardProduct - && string.Equals(sslProductVariant, Constants.ApiV2.ProductVariantEv, StringComparison.OrdinalIgnoreCase) - && extraDnsSans.Any(s => s.StartsWith("*.", StringComparison.Ordinal))) - { - _logger.LogError( - "EnrollV2Async rejected an EV order with a wildcard SAN on domain '{Domain}': EV has no " + - "wildcard product.", LogSanitizer.Strip(domain)); - _logger.MethodExit(LogLevel.Debug); - return new EnrollmentResult - { - CARequestID = string.Empty, - Certificate = null, - Status = (int)EndEntityStatus.FAILED, - StatusMessage = $"V2 enrollment rejected: the request carries a wildcard SAN, but EV has " + - $"no wildcard product (primary domain '{domain}'). No order was placed." - }; - } - _logger.LogInformation( "EnrollV2Async: product decided by CERTInext from the variant, wildcard shape and additional " + "domains. XProductCode={ProductCode}, ProductId={ProductId}, Wildcard={Wildcard}, Ucc={Ucc} " + @@ -2277,8 +2254,8 @@ private async Task EnrollV2CoreAsync( additionalDomains = null; _logger.LogInformation( - "EnrollV2Async: resolved UCC product. ProductCode={ProductCode}, AdditionalDomainCount={Count}", - productCode, additionalDomains?.Count ?? 0); + "EnrollV2Async: multi-domain (UCC) order. XProductCode={ProductCode}, AdditionalDomainCount={Count}", + productCode ?? "(none)", additionalDomains?.Count ?? 0); } // Private PKI additionalHosts: same SAN source rule as the UCC path diff --git a/CERTInext/Client/CERTInextClient.cs b/CERTInext/Client/CERTInextClient.cs index 2e7ba8d..e417f07 100644 --- a/CERTInext/Client/CERTInextClient.cs +++ b/CERTInext/Client/CERTInextClient.cs @@ -2309,9 +2309,10 @@ private List ParseProductDetailsV2Response(string content) } else if (element.TryGetProperty("productCode", out var fpc)) { - // Flat row shaped like ProductDetail. Read field by field like the branches around it: - // deserializing would leave Active false when the row has no "active" field, and throw on - // a numeric productTypeID. + // Flat row shaped like ProductDetail. Read field by field like the branches around it, because + // deserializing throws on a numeric productTypeID. A row with no (or a null) "active" is + // available, as in the other branches; JSON true/false is used as given; any other value + // ("false", 0) isn't trusted as active. result.Add(new ProductDetail { ProductCode = fpc.ValueKind == JsonValueKind.String ? fpc.GetString() : fpc.ToString(), @@ -2320,7 +2321,9 @@ private List ParseProductDetailsV2Response(string content) ProductTypeId = element.TryGetProperty("productTypeID", out var fpt) ? (fpt.ValueKind == JsonValueKind.String ? fpt.GetString() : fpt.ToString()) : null, - Active = !element.TryGetProperty("active", out var fa) || fa.ValueKind != JsonValueKind.False + Active = !element.TryGetProperty("active", out var fa) + || fa.ValueKind == JsonValueKind.Null + || fa.ValueKind == JsonValueKind.True }); } else if (element.TryGetProperty("productId", out var pid)) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d12000..59b21e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,9 +21,10 @@ - feat(config): V2 orders honor `GroupNumber`, `OrganizationNumber`, `TechnicalContact*`, `EmailNotifications`, and the subscription renewal settings. ## Bug Fixes -- fix(v2): A request whose CN is a plain name and whose SANs carry a wildcard (CN `example.com`, SAN `*.example.com`) keeps the CN as the domain and sends the wildcard in `additionalDomains`, with no `X-Product-Code` unless the template sets `ProductCode` (CERTInext's guidance is to send only the variant). An EV request in this shape is rejected before ordering, since EV has no wildcard product. +- fix(v2): A request whose CN is a plain name and whose SANs carry a wildcard (CN `example.com`, SAN `*.example.com`) keeps the CN as the domain and sends the wildcard in `additionalDomains`, with no `X-Product-Code` unless the template sets `ProductCode` (CERTInext's guidance is to send only the variant). - fix(v2): With an explicit `ProductCode`, extra SANs (including a wildcard SAN) are sent as `additionalDomains` instead of being rejected because the catalog lists the code as a single-domain product. Enrollment decides from the request, as it does without a `ProductCode`. -- fix(v2): Flat catalog rows with a `productCode` key are read as available when they have no `active` field, and a numeric `productTypeID` no longer fails the catalog read. +- fix(v2): Command's SAN list is the only source of an SSL order's extra names, as in the other Keyfactor CA plugins that build a SAN list. A DNS name that is only in the CSR no longer makes the order multi-domain (it used to do so while being left out of `additionalDomains`); the CSR is still sent unchanged, and its SANs are used only when the gateway passes no SAN list. +- fix(v2): A numeric `productTypeID` in a flat catalog row (keyed by `productCode`) no longer fails the catalog read. - fix(v2): A 422 `EMS-1165` from Download Certificate on an order CERTInext reports as `issued` is treated as "certificate not generated yet": the enrollment pickup keeps polling and returns pending, logging per attempt at Debug and one Information summary instead of a warning each time. `GetSingleRecord` and Synchronize log it quietly too (the sync summary gains `IssuedNotGeneratedYet`), and the log lines include CERTInext's `orderState` and `certificateState`. Other download errors still warn. - fix(v2): `EmailNotifications=0` (silent) is sent as `consent-only` on V2 order create, the quietest value in the spec's `consent-only | all` enum; the old `"0"` isn't a member of it. - fix(v2): Order create no longer sends `agreement.signerIp`, which isn't in the V2 spec's `Agreement` schema; the `SignerIp` settings now apply to V1 only. diff --git a/docsource/architecture.md b/docsource/architecture.md index 8a5835a..d94fc1d 100644 --- a/docsource/architecture.md +++ b/docsource/architecture.md @@ -398,9 +398,7 @@ flowchart TD C -- Yes --> D{Private PKI?} D -- Yes --> G0 D -- No --> E2["Detect UCC and wildcard from the request:
wildcard domain, UCC template product or extra DNS SANs"] - E2 --> F2{"EV with a wildcard SAN?"} - F2 -- Yes --> X3(["Failed result, no order placed"]) - F2 -- No --> G0{"SSL/TLS with V2InlineCsr on?
(Private PKI never)"} + E2 --> G0{"SSL/TLS with V2InlineCsr on?
(Private PKI never)"} G0 -- "No: two-call (V2InlineCsr false, or Private PKI)" --> G["Create the order without a CSR
(Idempotency-Key header, X-Product-Code only if the template sets ProductCode)"] G0 -- "Yes: single call, the default" --> GI["Create the order with the CSR inline, unchanged
(Idempotency-Key header, X-Product-Code only if the template sets ProductCode)"] GI --> GI2{"Create call answered?"} @@ -438,7 +436,7 @@ flowchart TD Notes on the V2 flow: - **Product code.** The spec makes `X-Product-Code` an optional override: CERTInext picks the catalog product itself from the variant, whether the domain is a wildcard (starts with `*.`), and whether `additionalDomains` is non-empty. CERTInext advises sending only the variant, so the plugin sends the header only when the template sets `ProductCode` (or the deprecated `ProfileId`), and sends it as given. The connector's `DefaultProductCode` doesn't affect V2 orders. The create response's `resolvedProductCode` is logged at Information level. - - **No product-code pre-check.** Enrollment never reads the catalog, with or without `ProductCode`; CERTInext rejects a code it can't use. The order is a wildcard when the domain starts with `*.`. It is multi-domain when the selected product is a UCC product, or when the CSR or SAN list has DNS names beyond the primary domain (its `www.` variant, and a wildcard's bare apex, don't count); those names go out as `additionalDomains`, which is what makes CERTInext choose a UCC product. An EV request with a wildcard SAN is rejected before ordering, since EV has no wildcard product. + - **No product-code pre-check.** Enrollment never reads the catalog, with or without `ProductCode`; CERTInext rejects a code it can't use. The order is a wildcard when the domain starts with `*.`. It is multi-domain when the selected product is a UCC product, or when the gateway's SAN list has DNS names beyond the primary domain (its `www.` variant, and a wildcard's bare apex, don't count); those names go out as `additionalDomains`, which is what makes CERTInext choose a UCC product. Command's SAN list is authoritative: a name only in the CSR is ignored (the CSR is still sent unchanged), and the CSR's SANs are used only when the gateway passes no SAN list. This matches the other Keyfactor CA plugins that build a SAN list for their CA. - **SSL.com organization validation (OV/EV).** Just before the create call, an OV or EV SSL/TLS order reads the organization's SSL.com validation status, refreshes it once if the order's level isn't validated, and, only when `SslComSubmitOrganization` is on and the organization is ready, submits it (accepting SSL.com's subscriber agreement on its behalf, audit-logged). This step is advisory: any failure or not-validated result logs a warning and the order is placed anyway. See [SSL.com organization validation](configuration.md#sslcom-organization-validation). - **Multi-domain products.** DNS SANs other than the primary domain are sent as `additionalDomains`, and non-DNS SANs are left off the order with a warning. Private PKI sends DNS and IP SANs as `additionalHosts`. - **CSR delivery (`V2InlineCsr`).** By default (`V2InlineCsr = true`, SSL/TLS) the CSR is sent inline in the create body exactly as Command supplied it, and there is no Submit CSR step (a `PUT .../csr` after an inline CSR is rejected with HTTP 422). The create call then often holds about 20 seconds until the certificate is issued, and the order ID is known only once it returns. If that call fails with a 5xx or times out, the order may still exist and issue: the failure message says so, the plugin doesn't cancel the order, and the next sync imports it. Private PKI ignores the setting and always uses two calls, because CERTInext rejects an inline CSR on the Private PKI create (HTTP 422). With `V2InlineCsr = false` the plugin creates the order without a CSR and then submits it with `PUT .../csr`, cancelling the orphaned order once if that submit is rejected. That two-call flow fails for a domain the account has already validated: CERTInext reports the order `issued` at create, before any CSR, and then rejects the submit with HTTP 422 "Something went Wrong". A blank CSR is rejected before any CA call. diff --git a/docsource/configuration.md b/docsource/configuration.md index cb9e371..c89a07b 100644 --- a/docsource/configuration.md +++ b/docsource/configuration.md @@ -579,8 +579,9 @@ CERTInext advises sending only the variant and leaving `X-Product-Code` out, so 1. **No `ProductCode` on the template (the default and recommended)** — no `X-Product-Code` header is sent. The connector's `DefaultProductCode` is not used. Neither save-time validation nor enrollment reads the catalog. The plugin decides whether the order is wildcard or multi-domain from the request itself: - **Wildcard:** the primary domain starts with `*.`. - - **Multi-domain:** the selected product is a UCC product, or the CSR or gateway SAN list carries DNS names beyond the primary domain (its `www.` variant, and a wildcard's bare apex, don't count). Those names are sent as `additionalDomains`, which makes CERTInext choose a UCC product. - - **Wildcard in the SANs only:** the CN is a plain name, such as `example.com`, and a SAN is a wildcard, such as `*.example.com`. The CN stays the domain (CERTInext requires the domain to match the CSR CN, `EMS-1056`), and the wildcard is sent in `additionalDomains`. EV has no wildcard product, so EV requests in this shape are rejected before any order is placed. + - **Multi-domain:** the selected product is a UCC product, or the gateway's SAN list carries DNS names beyond the primary domain (its `www.` variant, and a wildcard's bare apex, don't count). Those names are sent as `additionalDomains`, which makes CERTInext choose a UCC product. + - **SAN source:** Command's SAN list (passed by the gateway) is authoritative. A DNS name that is only in the CSR doesn't make the order multi-domain and isn't sent in `additionalDomains`; the CSR itself is still sent to CERTInext unchanged. The CSR's SANs are used only when the gateway passes no SAN list at all. This matches the other Keyfactor CA plugins that build a SAN list for their CA. + - **Wildcard in the SANs only:** the CN is a plain name, such as `example.com`, and a SAN is a wildcard, such as `*.example.com`. The CN stays the domain (CERTInext requires the domain to match the CSR CN, `EMS-1056`), and the wildcard is sent in `additionalDomains`. On some accounts CERTInext rejects this shape with `EMS-1173 Invalid Additional Domain Names` (seen on an emSign-backed sandbox account); if it does, set `ProductCode` on the template to the account's Wildcard UCC product code. 2. **Explicit `ProductCode` (or the deprecated `ProfileId` alias)** — the override. It is sent as-is in the `X-Product-Code` header. CERTInext advises against sending it, so use it only when your account holds several matching products (for example different CA profiles for the same variant) and you want to force one. The plugin doesn't check the code against the catalog, either when the template is saved or at enrollment. It decides wildcard and multi-domain from the request the same way as without an override, and CERTInext rejects a code that doesn't exist or can't carry the request. This differs from V1, where `DefaultProductCode` only affects renewals (see [DefaultProductCode](#defaultproductcode)). diff --git a/docsource/migration-v1-to-v2.md b/docsource/migration-v1-to-v2.md index fdd94d6..d99586b 100644 --- a/docsource/migration-v1-to-v2.md +++ b/docsource/migration-v1-to-v2.md @@ -17,7 +17,7 @@ and Synchronize — to V2. The two APIs cannot be mixed on a single connector. - **Multi-domain (UCC) certificates are supported.** That covers DV UCC, DV Wildcard UCC, OV UCC, OV Wildcard UCC, and EV UCC. The plugin treats a request as multi-domain when the selected product is a UCC product or the request carries extra DNS names, and sends those names in the order's `additionalDomains` field. Per the V2 spec, a UCC order's SANs come from the order, not the CSR. - **Only DNS SANs are sent.** `additionalDomains` takes DNS names only, so IP, email, and URI SANs are left off a UCC order and a warning is written to the gateway log. -- **Non-UCC SSL products are checked up front.** A CSR or SAN list with DNS names beyond the primary domain and its `www.` variant is rejected before any order is placed. UCC products are exempt. +- **Extra SAN names make an order multi-domain.** DNS names in Command's SAN list beyond the primary domain and its `www.` variant go out in `additionalDomains`, whatever product the template selects; CERTInext rejects a product that can't carry them. A name that is only in the CSR is ignored. - **DCV is not validated end to end in three cases.** These are per-SAN DCV on UCC orders, a domain that has never been validated, and wildcard DCV. The plugin runs the DNS-01 flow for each domain CERTInext reports as not yet validated, but test each UCC or wildcard template on the sandbox before relying on it in production. Keep it on a V1 connector if you need a validated path today. - **DCV needs a DNS provider plugin.** `DcvEnabled` defaults to `true`. Without a DNS provider plugin for the order's domains, V2 DV orders stay pending after the order is placed. Deploy one, or set `DcvEnabled` to `false` and validate domains another way. See [DCV under V2](#dcv-under-v2). From bb1d8567f53d7887f348ed8522c4072a64e482b8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 17 Nov 2026 19:56:05 +0000 Subject: [PATCH 09/12] docs: auto-generate README and documentation [skip ci] --- README.md | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ab5bbd6..9f26251 100644 --- a/README.md +++ b/README.md @@ -632,8 +632,9 @@ CERTInext advises sending only the variant and leaving `X-Product-Code` out, so 1. **No `ProductCode` on the template (the default and recommended)** — no `X-Product-Code` header is sent. The connector's `DefaultProductCode` is not used. Neither save-time validation nor enrollment reads the catalog. The plugin decides whether the order is wildcard or multi-domain from the request itself: - **Wildcard:** the primary domain starts with `*.`. - - **Multi-domain:** the selected product is a UCC product, or the CSR or gateway SAN list carries DNS names beyond the primary domain (its `www.` variant, and a wildcard's bare apex, don't count). Those names are sent as `additionalDomains`, which makes CERTInext choose a UCC product. - - **Wildcard in the SANs only:** the CN is a plain name, such as `example.com`, and a SAN is a wildcard, such as `*.example.com`. The CN stays the domain (CERTInext requires the domain to match the CSR CN, `EMS-1056`), and the wildcard is sent in `additionalDomains`. EV has no wildcard product, so EV requests in this shape are rejected before any order is placed. + - **Multi-domain:** the selected product is a UCC product, or the gateway's SAN list carries DNS names beyond the primary domain (its `www.` variant, and a wildcard's bare apex, don't count). Those names are sent as `additionalDomains`, which makes CERTInext choose a UCC product. + - **SAN source:** Command's SAN list (passed by the gateway) is authoritative. A DNS name that is only in the CSR doesn't make the order multi-domain and isn't sent in `additionalDomains`; the CSR itself is still sent to CERTInext unchanged. The CSR's SANs are used only when the gateway passes no SAN list at all. This matches the other Keyfactor CA plugins that build a SAN list for their CA. + - **Wildcard in the SANs only:** the CN is a plain name, such as `example.com`, and a SAN is a wildcard, such as `*.example.com`. The CN stays the domain (CERTInext requires the domain to match the CSR CN, `EMS-1056`), and the wildcard is sent in `additionalDomains`. On some accounts CERTInext rejects this shape with `EMS-1173 Invalid Additional Domain Names` (seen on an emSign-backed sandbox account); if it does, set `ProductCode` on the template to the account's Wildcard UCC product code. 2. **Explicit `ProductCode` (or the deprecated `ProfileId` alias)** — the override. It is sent as-is in the `X-Product-Code` header. CERTInext advises against sending it, so use it only when your account holds several matching products (for example different CA profiles for the same variant) and you want to force one. The plugin doesn't check the code against the catalog, either when the template is saved or at enrollment. It decides wildcard and multi-domain from the request the same way as without an override, and CERTInext rejects a code that doesn't exist or can't carry the request. This differs from V1, where `DefaultProductCode` only affects renewals (see [DefaultProductCode](#defaultproductcode)). @@ -758,7 +759,7 @@ and Synchronize — to V2. The two APIs cannot be mixed on a single connector. - **Multi-domain (UCC) certificates are supported.** That covers DV UCC, DV Wildcard UCC, OV UCC, OV Wildcard UCC, and EV UCC. The plugin treats a request as multi-domain when the selected product is a UCC product or the request carries extra DNS names, and sends those names in the order's `additionalDomains` field. Per the V2 spec, a UCC order's SANs come from the order, not the CSR. - **Only DNS SANs are sent.** `additionalDomains` takes DNS names only, so IP, email, and URI SANs are left off a UCC order and a warning is written to the gateway log. -- **Non-UCC SSL products are checked up front.** A CSR or SAN list with DNS names beyond the primary domain and its `www.` variant is rejected before any order is placed. UCC products are exempt. +- **Extra SAN names make an order multi-domain.** DNS names in Command's SAN list beyond the primary domain and its `www.` variant go out in `additionalDomains`, whatever product the template selects; CERTInext rejects a product that can't carry them. A name that is only in the CSR is ignored. - **DCV is not validated end to end in three cases.** These are per-SAN DCV on UCC orders, a domain that has never been validated, and wildcard DCV. The plugin runs the DNS-01 flow for each domain CERTInext reports as not yet validated, but test each UCC or wildcard template on the sandbox before relying on it in production. Keep it on a V1 connector if you need a validated path today. - **DCV needs a DNS provider plugin.** `DcvEnabled` defaults to `true`. Without a DNS provider plugin for the order's domains, V2 DV orders stay pending after the order is placed. Deploy one, or set `DcvEnabled` to `false` and validate domains another way. See [DCV under V2](#dcv-under-v2). @@ -1373,9 +1374,7 @@ flowchart TD C -- Yes --> D{Private PKI?} D -- Yes --> G0 D -- No --> E2["Detect UCC and wildcard from the request:
wildcard domain, UCC template product or extra DNS SANs"] - E2 --> F2{"EV with a wildcard SAN?"} - F2 -- Yes --> X3(["Failed result, no order placed"]) - F2 -- No --> G0{"SSL/TLS with V2InlineCsr on?
(Private PKI never)"} + E2 --> G0{"SSL/TLS with V2InlineCsr on?
(Private PKI never)"} G0 -- "No: two-call (V2InlineCsr false, or Private PKI)" --> G["Create the order without a CSR
(Idempotency-Key header, X-Product-Code only if the template sets ProductCode)"] G0 -- "Yes: single call, the default" --> GI["Create the order with the CSR inline, unchanged
(Idempotency-Key header, X-Product-Code only if the template sets ProductCode)"] GI --> GI2{"Create call answered?"} @@ -1413,7 +1412,7 @@ flowchart TD Notes on the V2 flow: - **Product code.** The spec makes `X-Product-Code` an optional override: CERTInext picks the catalog product itself from the variant, whether the domain is a wildcard (starts with `*.`), and whether `additionalDomains` is non-empty. CERTInext advises sending only the variant, so the plugin sends the header only when the template sets `ProductCode` (or the deprecated `ProfileId`), and sends it as given. The connector's `DefaultProductCode` doesn't affect V2 orders. The create response's `resolvedProductCode` is logged at Information level. - - **No product-code pre-check.** Enrollment never reads the catalog, with or without `ProductCode`; CERTInext rejects a code it can't use. The order is a wildcard when the domain starts with `*.`. It is multi-domain when the selected product is a UCC product, or when the CSR or SAN list has DNS names beyond the primary domain (its `www.` variant, and a wildcard's bare apex, don't count); those names go out as `additionalDomains`, which is what makes CERTInext choose a UCC product. An EV request with a wildcard SAN is rejected before ordering, since EV has no wildcard product. + - **No product-code pre-check.** Enrollment never reads the catalog, with or without `ProductCode`; CERTInext rejects a code it can't use. The order is a wildcard when the domain starts with `*.`. It is multi-domain when the selected product is a UCC product, or when the gateway's SAN list has DNS names beyond the primary domain (its `www.` variant, and a wildcard's bare apex, don't count); those names go out as `additionalDomains`, which is what makes CERTInext choose a UCC product. Command's SAN list is authoritative: a name only in the CSR is ignored (the CSR is still sent unchanged), and the CSR's SANs are used only when the gateway passes no SAN list. This matches the other Keyfactor CA plugins that build a SAN list for their CA. - **SSL.com organization validation (OV/EV).** Just before the create call, an OV or EV SSL/TLS order reads the organization's SSL.com validation status, refreshes it once if the order's level isn't validated, and, only when `SslComSubmitOrganization` is on and the organization is ready, submits it (accepting SSL.com's subscriber agreement on its behalf, audit-logged). This step is advisory: any failure or not-validated result logs a warning and the order is placed anyway. See [SSL.com organization validation](configuration.md#sslcom-organization-validation). - **Multi-domain products.** DNS SANs other than the primary domain are sent as `additionalDomains`, and non-DNS SANs are left off the order with a warning. Private PKI sends DNS and IP SANs as `additionalHosts`. - **CSR delivery (`V2InlineCsr`).** By default (`V2InlineCsr = true`, SSL/TLS) the CSR is sent inline in the create body exactly as Command supplied it, and there is no Submit CSR step (a `PUT .../csr` after an inline CSR is rejected with HTTP 422). The create call then often holds about 20 seconds until the certificate is issued, and the order ID is known only once it returns. If that call fails with a 5xx or times out, the order may still exist and issue: the failure message says so, the plugin doesn't cancel the order, and the next sync imports it. Private PKI ignores the setting and always uses two calls, because CERTInext rejects an inline CSR on the Private PKI create (HTTP 422). With `V2InlineCsr = false` the plugin creates the order without a CSR and then submits it with `PUT .../csr`, cancelling the orphaned order once if that submit is rejected. That two-call flow fails for a domain the account has already validated: CERTInext reports the order `issued` at create, before any CSR, and then rejects the submit with HTTP 422 "Something went Wrong". A blank CSR is rejected before any CA call. From b2404f5c5906965b5b38fead6cdb7a178fbbfb96 Mon Sep 17 00:00:00 2001 From: spbsoluble <1661003+spbsoluble@users.noreply.github.com> Date: Tue, 17 Nov 2026 12:00:28 -0800 Subject: [PATCH 10/12] docs(changelog): consolidate the V2 product-code entries; add an upgrade note and known limitations Merges the two overlapping X-Product-Code/ProductCode feature entries into one that describes the final behavior, tightens the related fixes, adds an upgrade note for earlier 2.0 builds (no save-time ProductCode check; CSR-only SAN names ignored), and lists EMS-1173 on wildcard-only-in-SANs requests and the missing live verification as known limitations. --- CHANGELOG.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59b21e5..12450f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,12 +3,11 @@ ## Features - feat(v2): Opt-in CERTInext V2 REST API via `UseV2Api` (default `false`), authenticated with OAuth2 `client_credentials`. - feat(v2): Enroll, renew, reissue, revoke, and synchronize SSL/TLS and Private PKI products, selected with the `ProductFamily` and `ProductVariant` template parameters. -- feat(v2): A template's `ProductCode` is an optional override, sent as given in `X-Product-Code`. The plugin doesn't check it against the V2 catalog when the template is saved or at enrollment; CERTInext rejects a code it can't use. - feat(v2): Multi-domain (UCC) and wildcard SSL/TLS enrollment, with extra SANs sent as `additionalDomains`. - feat(v2): New OV template parameters `OrgRepresentativeName`, `OrgRepresentativeEmail`, `OrgRepresentativePhone`, `OrgRepresentativeDesignation` and `OrgRepresentativeEmployeeId` register a new Organization Representative on a V2 OV order (`useNewOrgRepresentative`). CERTInext's rules (OV only, a pre-vetted organization, name and email together, a 6-15 digit phone) are checked when the template is saved and before any CA call. The response's `organizationRepresentativeStatus` (`applied` or `pending-approval`) is logged, and the representative's details are never logged. - feat(v2): V2 OV and EV SSL/TLS orders check the organization's SSL.com validation first (status read, one refresh, and an optional submission). New settings `SslComSubmitOrganization` (default `false`; enabling it accepts SSL.com's subscriber agreement on the organization's behalf, audit-logged) and `SslComAdminEmail`. A not-validated organization or a failed SSL.com call only warns, and the order is placed anyway. - feat(v2): An SSL/TLS order that Track Order shows at `pending-agreement` gets the Subscriber Agreement accepted via `POST /ssl-certificates/{orderId}/agreement`, using the same signer values as create: at most once per order per enroll call or sync pass, audit-logged first, and a failure only warns. -- feat(v2): The create call no longer sends `X-Product-Code` unless the template sets `ProductCode` (SSL/TLS and Private PKI): CERTInext resolves the product from the variant, wildcard shape and `additionalDomains`, and the response's `resolvedProductCode` is logged. An ambiguous catalog match is no longer an error, Private PKI no longer needs `ProductCode`, and without one a wildcard is detected from the `*.` domain and a UCC order from the template's product or extra DNS SANs. +- feat(v2): The create call sends `X-Product-Code` only when the template sets `ProductCode` (SSL/TLS and Private PKI), following CERTInext's guidance to send only the variant. CERTInext resolves the product from the variant, wildcard shape and `additionalDomains`, and the response's `resolvedProductCode` is logged. A template's `ProductCode` is an optional override sent as given: the plugin doesn't check it against the catalog when the template is saved or at enrollment, and CERTInext rejects a code it can't use. Private PKI doesn't need `ProductCode`. Wildcard is detected from a `*.` domain, and a multi-domain (UCC) order from the template's product or extra DNS names in Command's SAN list. - feat(v2): V2 SSL/TLS enrollment sends the CSR inline in one create call (`V2InlineCsr`, default `true`). Setting it to `false` selects create + Submit CSR, which fails for a domain the account has already validated; Private PKI stays two-call. - feat(v2): An SSL/TLS reissue (`Reissue`, or `RenewOrReissue` outside `RenewalWindowDays`) calls `POST /ssl-certificates/{orderId}/reissue` in `rekey` mode with the new CSR, and the derived order (for example `1984857369R001`) becomes the new `CARequestID`. New setting `V2ReissueRevokePrevious` (default `false`) also revokes the previous certificate as `superseded`, audit-logged first. A missing prior order or a 404/422 places a new order instead and says so; a 5xx or lost response fails with "do not resubmit". Not verified live: the sandbox no longer generates certificates. - feat(v2): Synchronize reads `/reports/orders` and honors `IgnoreExpired`. @@ -21,8 +20,8 @@ - feat(config): V2 orders honor `GroupNumber`, `OrganizationNumber`, `TechnicalContact*`, `EmailNotifications`, and the subscription renewal settings. ## Bug Fixes -- fix(v2): A request whose CN is a plain name and whose SANs carry a wildcard (CN `example.com`, SAN `*.example.com`) keeps the CN as the domain and sends the wildcard in `additionalDomains`, with no `X-Product-Code` unless the template sets `ProductCode` (CERTInext's guidance is to send only the variant). -- fix(v2): With an explicit `ProductCode`, extra SANs (including a wildcard SAN) are sent as `additionalDomains` instead of being rejected because the catalog lists the code as a single-domain product. Enrollment decides from the request, as it does without a `ProductCode`. +- fix(v2): A request whose CN is a plain name and whose SANs carry a wildcard (CN `example.com`, SAN `*.example.com`) is no longer rejected before ordering when the catalog has no single Wildcard UCC product. It keeps the CN as the domain and sends the wildcard in `additionalDomains`, with no `X-Product-Code` unless the template sets `ProductCode`. +- fix(v2): Extra SANs on an order with an explicit `ProductCode` are sent as `additionalDomains` instead of being rejected because the catalog lists the code as a single-domain product. - fix(v2): Command's SAN list is the only source of an SSL order's extra names, as in the other Keyfactor CA plugins that build a SAN list. A DNS name that is only in the CSR no longer makes the order multi-domain (it used to do so while being left out of `additionalDomains`); the CSR is still sent unchanged, and its SANs are used only when the gateway passes no SAN list. - fix(v2): A numeric `productTypeID` in a flat catalog row (keyed by `productCode`) no longer fails the catalog read. - fix(v2): A 422 `EMS-1165` from Download Certificate on an order CERTInext reports as `issued` is treated as "certificate not generated yet": the enrollment pickup keeps polling and returns pending, logging per attempt at Debug and one Information summary instead of a warning each time. `GetSingleRecord` and Synchronize log it quietly too (the sync summary gains `IssuedNotGeneratedYet`), and the log lines include CERTInext's `orderState` and `certificateState`. Other download errors still warn. @@ -60,6 +59,7 @@ - Connectors saved with an `http` `ApiUrl` fail to start until the URL uses https. - V2 no longer sends `X-Product-Code` unless the template sets `ProductCode`, and `DefaultProductCode` no longer applies to V2 orders. A template that needs a specific one of several matching catalog products must set `ProductCode`. - V2 connectors require `SignerPlace`, and V2 OV/EV orders require `OrganizationNumber`. +- If you ran an earlier 2.0 build: saving a V2 template no longer checks `ProductCode` against the catalog, so a wrong code now fails at the first enrollment with CERTInext's error instead of at save time. A DNS name that is only in the CSR, not in Command's SAN list, is no longer added to the order. V1 templates are still checked when saved. - `V2InlineCsr` now defaults to `true`. A connector that already has `V2InlineCsr = false` saved, as connectors created with an earlier 2.0 build do, keeps the two-call flow, which fails for already-validated domains. Set it to `true` on those connectors. - `SignerIp` (connector and template) is V1 only: V2 no longer sends `agreement.signerIp`, which the V2 spec's agreement schema doesn't define. - V2 `ProductVariant` is derived from the selected product when unset. @@ -80,6 +80,8 @@ - V1 `AuthMode=OAuth` isn't supported: the live V1 API ignores the bearer token, so V1 needs an access key. - The V2 incremental sync doesn't yet skip orders the gateway already holds unchanged, as the V1 incremental sync does from 1.0.2, so it re-reads each order listed. - Without a template `ProductCode`, the product CERTInext resolves depends on the account's catalog. Where several products match a variant, CERTInext may pick one that rejects a client CSR. On the sandbox, plain DV resolves to `917` "SSL DV 1 month" instead of `842`. Set `ProductCode` on the template to choose the product. +- On some accounts CERTInext rejects a request with a wildcard only in the SANs (CN `example.com`, SAN `*.example.com`) and no `ProductCode` with `EMS-1173 Invalid Additional Domain Names` (seen on an emSign-backed sandbox account). Set `ProductCode` on the template to the account's Wildcard UCC product code. +- Leaving out `X-Product-Code`, the wildcard-only-in-SANs shape, and taking extra names only from Command's SAN list aren't verified live: since 2026-11-17 the sandbox API rejects every SSL order with `EMS-1358`. - DCV for domains validated by SSL.com is built from the V2 spec and unit-tested but not verified live (the sandbox has no SSL.com-validated domains). Only SSL.com's `dns-txt` option can be published, because the DNS provider interface publishes TXT records only; a domain offered only `dns-cname` or `http-url` stays pending. - Inline DCV during `Enroll` isn't bounded by `EnrollmentCallBudgetSeconds` (it has its own `DcvTimeoutMinutes`), so an enrollment that runs DCV inline can still outlast Command's Workflow Step Run Timeout (60 s by default). Command then records the enrollment as failed even though the order continues at CERTInext, and the certificate arrives through a later sync. Raise that Command setting if inline DCV is slow. From 6ca52e7fca644b51b08008747c2df29226d05f0c Mon Sep 17 00:00:00 2001 From: spbsoluble <1661003+spbsoluble@users.noreply.github.com> Date: Tue, 17 Nov 2026 12:03:00 -0800 Subject: [PATCH 11/12] docs(changelog): drop test-environment references and meta notes from 2.0.0 Removes sandbox and live-test references, test dates, rationale asides and the notes aimed at pre-release builds from the 2.0.0 entries, and the same sandbox aside from the configuration doc. --- CHANGELOG.md | 28 +++++++++++++--------------- docsource/configuration.md | 2 +- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12450f8..6392f41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,9 +7,9 @@ - feat(v2): New OV template parameters `OrgRepresentativeName`, `OrgRepresentativeEmail`, `OrgRepresentativePhone`, `OrgRepresentativeDesignation` and `OrgRepresentativeEmployeeId` register a new Organization Representative on a V2 OV order (`useNewOrgRepresentative`). CERTInext's rules (OV only, a pre-vetted organization, name and email together, a 6-15 digit phone) are checked when the template is saved and before any CA call. The response's `organizationRepresentativeStatus` (`applied` or `pending-approval`) is logged, and the representative's details are never logged. - feat(v2): V2 OV and EV SSL/TLS orders check the organization's SSL.com validation first (status read, one refresh, and an optional submission). New settings `SslComSubmitOrganization` (default `false`; enabling it accepts SSL.com's subscriber agreement on the organization's behalf, audit-logged) and `SslComAdminEmail`. A not-validated organization or a failed SSL.com call only warns, and the order is placed anyway. - feat(v2): An SSL/TLS order that Track Order shows at `pending-agreement` gets the Subscriber Agreement accepted via `POST /ssl-certificates/{orderId}/agreement`, using the same signer values as create: at most once per order per enroll call or sync pass, audit-logged first, and a failure only warns. -- feat(v2): The create call sends `X-Product-Code` only when the template sets `ProductCode` (SSL/TLS and Private PKI), following CERTInext's guidance to send only the variant. CERTInext resolves the product from the variant, wildcard shape and `additionalDomains`, and the response's `resolvedProductCode` is logged. A template's `ProductCode` is an optional override sent as given: the plugin doesn't check it against the catalog when the template is saved or at enrollment, and CERTInext rejects a code it can't use. Private PKI doesn't need `ProductCode`. Wildcard is detected from a `*.` domain, and a multi-domain (UCC) order from the template's product or extra DNS names in Command's SAN list. +- feat(v2): The create call sends `X-Product-Code` only when the template sets `ProductCode` (SSL/TLS and Private PKI). CERTInext resolves the product from the variant, wildcard shape and `additionalDomains`, and the response's `resolvedProductCode` is logged. A template's `ProductCode` is an optional override sent as given: the plugin doesn't check it against the catalog when the template is saved or at enrollment, and CERTInext rejects a code it can't use. Private PKI doesn't need `ProductCode`. Wildcard is detected from a `*.` domain, and a multi-domain (UCC) order from the template's product or extra DNS names in Command's SAN list. - feat(v2): V2 SSL/TLS enrollment sends the CSR inline in one create call (`V2InlineCsr`, default `true`). Setting it to `false` selects create + Submit CSR, which fails for a domain the account has already validated; Private PKI stays two-call. -- feat(v2): An SSL/TLS reissue (`Reissue`, or `RenewOrReissue` outside `RenewalWindowDays`) calls `POST /ssl-certificates/{orderId}/reissue` in `rekey` mode with the new CSR, and the derived order (for example `1984857369R001`) becomes the new `CARequestID`. New setting `V2ReissueRevokePrevious` (default `false`) also revokes the previous certificate as `superseded`, audit-logged first. A missing prior order or a 404/422 places a new order instead and says so; a 5xx or lost response fails with "do not resubmit". Not verified live: the sandbox no longer generates certificates. +- feat(v2): An SSL/TLS reissue (`Reissue`, or `RenewOrReissue` outside `RenewalWindowDays`) calls `POST /ssl-certificates/{orderId}/reissue` in `rekey` mode with the new CSR, and the derived order (for example `1984857369R001`) becomes the new `CARequestID`. New setting `V2ReissueRevokePrevious` (default `false`) also revokes the previous certificate as `superseded`, audit-logged first. A missing prior order or a 404/422 places a new order instead and says so; a 5xx or lost response fails with "do not resubmit". - feat(v2): Synchronize reads `/reports/orders` and honors `IgnoreExpired`. - feat(v2): Incremental syncs look back `V2SyncLookbackHours` (default 72). - feat(dcv): DNS-01 domain validation for V2 SSL/TLS orders, including every SAN on a UCC order. @@ -22,7 +22,7 @@ ## Bug Fixes - fix(v2): A request whose CN is a plain name and whose SANs carry a wildcard (CN `example.com`, SAN `*.example.com`) is no longer rejected before ordering when the catalog has no single Wildcard UCC product. It keeps the CN as the domain and sends the wildcard in `additionalDomains`, with no `X-Product-Code` unless the template sets `ProductCode`. - fix(v2): Extra SANs on an order with an explicit `ProductCode` are sent as `additionalDomains` instead of being rejected because the catalog lists the code as a single-domain product. -- fix(v2): Command's SAN list is the only source of an SSL order's extra names, as in the other Keyfactor CA plugins that build a SAN list. A DNS name that is only in the CSR no longer makes the order multi-domain (it used to do so while being left out of `additionalDomains`); the CSR is still sent unchanged, and its SANs are used only when the gateway passes no SAN list. +- fix(v2): Command's SAN list is the only source of an SSL order's extra names. A DNS name that is only in the CSR no longer makes the order multi-domain; the CSR is still sent unchanged, and its SANs are used only when the gateway passes no SAN list. - fix(v2): A numeric `productTypeID` in a flat catalog row (keyed by `productCode`) no longer fails the catalog read. - fix(v2): A 422 `EMS-1165` from Download Certificate on an order CERTInext reports as `issued` is treated as "certificate not generated yet": the enrollment pickup keeps polling and returns pending, logging per attempt at Debug and one Information summary instead of a warning each time. `GetSingleRecord` and Synchronize log it quietly too (the sync summary gains `IssuedNotGeneratedYet`), and the log lines include CERTInext's `orderState` and `certificateState`. Other download errors still warn. - fix(v2): `EmailNotifications=0` (silent) is sent as `consent-only` on V2 order create, the quietest value in the spec's `consent-only | all` enum; the old `"0"` isn't a member of it. @@ -37,12 +37,12 @@ - fix(logging): Email addresses inside CA error text in logged response bodies (problem+json `detail`/`title`, `message`, V1 `errorMessage`) are masked unless `LogSensitiveRequestData` is on. Before, only the exception message was masked, and the Warning-level `CERTInext V2 API non-success` line and the Trace response dump kept the email, for example the representative's address that an `EMS-1317` error echoes. - fix(enroll): V2 order and CSR submissions are never auto-retried after a timeout, which could create duplicate orders (V1 since 1.0.1). - fix(sync): A V2 order that `/reports/orders` lists but Track Order finds in no product family (seen for every `On Hold | Setup Pending` row) is skipped with one Information line and counted as `UntrackableListedOrders` in the sync summary. It used to log an error with a stack trace and count toward the sync's 25% error-rate abort. -- fix(sync): The V2 sync summary lists every `orderStatus | certificateStatus` pair from `/reports/orders` that the plugin didn't recognize, with counts (`UnmappedReportStatuses=[...]`), at Information. CERTInext doesn't document these values, so new ones now show up in ordinary logs. -- fix(enroll): New setting `EnrollmentCallBudgetSeconds` (default 50, `0` disables, at most 90). It bounds the in-call pickup wait by a deadline measured from the start of `Enroll`, so time spent creating or reissuing the order counts against it. Before, the 55 s default pickup started only after the create (a V2 reissue alone took about 26 s live), so Command failed the enrollment at its 60 s Workflow Step Run Timeout while the order went on at CERTInext. That invited a resubmit and a duplicate order. The pickup now shortens its waits, skips the delay after its last poll, and returns pending with one Information line when no further poll fits. Calls already in flight are never cut short, and `PickupRetries=0` still disables the pickup. Set it about 10 s below Command's Workflow Step Run Timeout if you raise that (V1 and V2). +- fix(sync): The V2 sync summary lists every `orderStatus | certificateStatus` pair from `/reports/orders` that the plugin didn't recognize, with counts (`UnmappedReportStatuses=[...]`), at Information. +- fix(enroll): New setting `EnrollmentCallBudgetSeconds` (default 50, `0` disables, at most 90). It bounds the in-call pickup wait by a deadline measured from the start of `Enroll`, so time spent creating or reissuing the order counts against it. Before, the 55 s default pickup started only after the create, so Command failed the enrollment at its 60 s Workflow Step Run Timeout while the order went on at CERTInext. That invited a resubmit and a duplicate order. The pickup now shortens its waits, skips the delay after its last poll, and returns pending with one Information line when no further poll fits. Calls already in flight are never cut short, and `PickupRetries=0` still disables the pickup. Set it about 10 s below Command's Workflow Step Run Timeout if you raise that (V1 and V2). - fix(sync): An order cancelled or rejected at CERTInext that the gateway still holds as pending is now emitted once as failed (V1 and V2). Both syncs skip cancelled and rejected orders, so such an order used to stay pending in the gateway indefinitely. The sync asks the gateway for the order's status first: an order it doesn't hold is still skipped, so no row is created for every cancelled order in the account, and an issued or revoked row is never changed. The sync summary gains `FailedPropagated`. - fix(sync): Synced certificates now report the product name (for example `DV SSL`) as their `ProductID`, not CERTInext's product code (V1 and V2), so the gateway can match them to a configured template and Command imports them with one. The gateway matches `ProductID` exactly against the templates' product names, so a code such as `842` never matched, and certificates ordered outside Command arrived in Command with no template. The code is named through the account's own product catalog (code → product type → name), read once per sync pass; a code the catalog can't name, or a catalog that can't be read (one warning), keeps the code as before. The sync summary gains `ProductNames: Resolved=…, Unresolved=…`. Certificates enrolled through Command keep the template Command recorded at enrollment. - fix(dcv): V2 DCV looks each domain up (`GET /domains`) once per sync pass, and once per `Enroll` or single-record call, instead of once per pending order and SAN. Found rows and "no row" are reused; a failed lookup is not, so the next order on that domain tries again. -- fix(sync): A V2 `/reports/orders` row that reads `Order Fulfilled | Pending for Approver` is resolved through Track Order, which returns `issued`, and its certificate is downloaded when one exists. It used to be reported as pending without a download attempt. When the download answers 422 `EMS-1165` (certificate not generated), the order is still reported as pending, as its certificate status says. `GetSingleRecord` does the same, reading Track Order's `certificateState`: an issued order with no certificate and a pending certificate state (for example `Approved by System`, as on the sandbox's recent orders) is returned as pending, not as issued without a certificate. Other disagreeing pairs, such as `Order Accepted | Certificate Revoked`, keep their mapping, because the certificate status is correct for them. +- fix(sync): A V2 `/reports/orders` row that reads `Order Fulfilled | Pending for Approver` is resolved through Track Order, which returns `issued`, and its certificate is downloaded when one exists. It used to be reported as pending without a download attempt. When the download answers 422 `EMS-1165` (certificate not generated), the order is still reported as pending, as its certificate status says. `GetSingleRecord` does the same, reading Track Order's `certificateState`: an issued order with no certificate and a pending certificate state (for example `Approved by System`) is returned as pending, not as issued without a certificate. Other disagreeing pairs, such as `Order Accepted | Certificate Revoked`, keep their mapping, because the certificate status is correct for them. - fix(v2): A V2 OAuth2 token request that gets no HTTP response (a dropped connection or other transport error) is retried twice, after 1 s and 3 s, so one network blip no longer fails an enrollment, a sync or a connector save. HTTP errors (400/401/403) are not retried, and order creates are still never retried. Token failures and other V2 calls with no response now log the transport detail (`TransportDetail=`: RestSharp's response status and the exception types and messages, with credentials removed) and include a short form in the error, instead of only `HttpStatus=0`. - fix(sync): The V2 sync also holds back pending and issued orders created in the last 120 s (`SyncRecentOrderGraceSeconds`, `0` disables), so an in-flight enrollment no longer fails with a duplicate key (V1 since 1.0.1). - fix(enroll): The in-call pickup wait is now capped at 75 s (it was 180 s) for V1 and V2, inside Command's roughly 100 s enrollment-call timeout, so a pickup that used its whole budget is no longer abandoned by Command. The 55 s default (`PickupRetries` 5, `PickupDelay` 10) is unaffected. @@ -59,11 +59,10 @@ - Connectors saved with an `http` `ApiUrl` fail to start until the URL uses https. - V2 no longer sends `X-Product-Code` unless the template sets `ProductCode`, and `DefaultProductCode` no longer applies to V2 orders. A template that needs a specific one of several matching catalog products must set `ProductCode`. - V2 connectors require `SignerPlace`, and V2 OV/EV orders require `OrganizationNumber`. -- If you ran an earlier 2.0 build: saving a V2 template no longer checks `ProductCode` against the catalog, so a wrong code now fails at the first enrollment with CERTInext's error instead of at save time. A DNS name that is only in the CSR, not in Command's SAN list, is no longer added to the order. V1 templates are still checked when saved. -- `V2InlineCsr` now defaults to `true`. A connector that already has `V2InlineCsr = false` saved, as connectors created with an earlier 2.0 build do, keeps the two-call flow, which fails for already-validated domains. Set it to `true` on those connectors. +- `V2InlineCsr` now defaults to `true`. A connector that already has `V2InlineCsr = false` saved keeps the two-call flow, which fails for already-validated domains. Set it to `true` on those connectors. - `SignerIp` (connector and template) is V1 only: V2 no longer sends `agreement.signerIp`, which the V2 spec's agreement schema doesn't define. - V2 `ProductVariant` is derived from the selected product when unset. -- V2 revoke reasons CERTInext rejects are retried with a substitute (see Revocation Reason Codes in the README). `privilege-withdrawn`, which the 2.0.0 V2 spec dropped from the SSL/TLS enum and CERTInext rejected live on 2026-11-13, is still sent first and now falls back to `cessation-of-operation`. The retry also recognizes CERTInext's newer 422 wording, "Revocation reason {reason} is not allowed." +- V2 revoke reasons CERTInext rejects are retried with a substitute (see Revocation Reason Codes in the README). `privilege-withdrawn`, which CERTInext no longer accepts for SSL/TLS, is still sent first and now falls back to `cessation-of-operation`. The retry also recognizes CERTInext's newer 422 wording, "Revocation reason {reason} is not allowed." - V2 `expired` orders are reported as issued, and revoking one is sent to the CA. - V2 renewals place a new order and don't revoke the original. V2 SSL/TLS reissues now go through the reissue endpoint and produce derived order ids such as `1984857369R001`, which aren't numeric. Scripts or reports that assume numeric `CARequestID`s need updating. Set `V2ReissueRevokePrevious` to `true` if a reissue should revoke the previous certificate. - On V2 accounts whose domains SSL.com validates, DCV now publishes SSL.com's record name and value, not `DcvTxtRecordTemplate`. The DNS provider plugin must be able to write those names (for example `_pki-validation.`). @@ -75,14 +74,13 @@ - Document Signer (`ProductFamily=signature`) enrollment isn't supported under V2. - Per-SAN DCV on UCC orders, DCV for a never-validated domain, and wildcard DCV aren't validated end to end against the CA. - Rolling a connector back to V1 after it has issued V2 certificates isn't validated. -- V2 SSL/TLS reissue through the reissue endpoint isn't verified live (the sandbox stopped generating certificates), and it always uses `rekey`, never `update-sans`. +- V2 SSL/TLS reissue always uses `rekey`, never `update-sans`. - V1 `IgnoreExpired` isn't applied yet; it works on V2. -- V1 `AuthMode=OAuth` isn't supported: the live V1 API ignores the bearer token, so V1 needs an access key. +- V1 `AuthMode=OAuth` isn't supported: the V1 API ignores the bearer token, so V1 needs an access key. - The V2 incremental sync doesn't yet skip orders the gateway already holds unchanged, as the V1 incremental sync does from 1.0.2, so it re-reads each order listed. -- Without a template `ProductCode`, the product CERTInext resolves depends on the account's catalog. Where several products match a variant, CERTInext may pick one that rejects a client CSR. On the sandbox, plain DV resolves to `917` "SSL DV 1 month" instead of `842`. Set `ProductCode` on the template to choose the product. -- On some accounts CERTInext rejects a request with a wildcard only in the SANs (CN `example.com`, SAN `*.example.com`) and no `ProductCode` with `EMS-1173 Invalid Additional Domain Names` (seen on an emSign-backed sandbox account). Set `ProductCode` on the template to the account's Wildcard UCC product code. -- Leaving out `X-Product-Code`, the wildcard-only-in-SANs shape, and taking extra names only from Command's SAN list aren't verified live: since 2026-11-17 the sandbox API rejects every SSL order with `EMS-1358`. -- DCV for domains validated by SSL.com is built from the V2 spec and unit-tested but not verified live (the sandbox has no SSL.com-validated domains). Only SSL.com's `dns-txt` option can be published, because the DNS provider interface publishes TXT records only; a domain offered only `dns-cname` or `http-url` stays pending. +- Without a template `ProductCode`, the product CERTInext resolves depends on the account's catalog. Where several products match a variant, CERTInext may pick one that rejects a client CSR. Set `ProductCode` on the template to choose the product. +- On some accounts CERTInext rejects a request with a wildcard only in the SANs (CN `example.com`, SAN `*.example.com`) and no `ProductCode` with `EMS-1173 Invalid Additional Domain Names`. Set `ProductCode` on the template to the account's Wildcard UCC product code. +- For domains validated by SSL.com, DCV can publish only SSL.com's `dns-txt` option, because the DNS provider interface publishes TXT records only; a domain offered only `dns-cname` or `http-url` stays pending. - Inline DCV during `Enroll` isn't bounded by `EnrollmentCallBudgetSeconds` (it has its own `DcvTimeoutMinutes`), so an enrollment that runs DCV inline can still outlast Command's Workflow Step Run Timeout (60 s by default). Command then records the enrollment as failed even though the order continues at CERTInext, and the certificate arrives through a later sync. Raise that Command setting if inline DCV is slow. # 1.0.2 diff --git a/docsource/configuration.md b/docsource/configuration.md index c89a07b..b8b8be8 100644 --- a/docsource/configuration.md +++ b/docsource/configuration.md @@ -581,7 +581,7 @@ CERTInext advises sending only the variant and leaving `X-Product-Code` out, so - **Wildcard:** the primary domain starts with `*.`. - **Multi-domain:** the selected product is a UCC product, or the gateway's SAN list carries DNS names beyond the primary domain (its `www.` variant, and a wildcard's bare apex, don't count). Those names are sent as `additionalDomains`, which makes CERTInext choose a UCC product. - **SAN source:** Command's SAN list (passed by the gateway) is authoritative. A DNS name that is only in the CSR doesn't make the order multi-domain and isn't sent in `additionalDomains`; the CSR itself is still sent to CERTInext unchanged. The CSR's SANs are used only when the gateway passes no SAN list at all. This matches the other Keyfactor CA plugins that build a SAN list for their CA. - - **Wildcard in the SANs only:** the CN is a plain name, such as `example.com`, and a SAN is a wildcard, such as `*.example.com`. The CN stays the domain (CERTInext requires the domain to match the CSR CN, `EMS-1056`), and the wildcard is sent in `additionalDomains`. On some accounts CERTInext rejects this shape with `EMS-1173 Invalid Additional Domain Names` (seen on an emSign-backed sandbox account); if it does, set `ProductCode` on the template to the account's Wildcard UCC product code. + - **Wildcard in the SANs only:** the CN is a plain name, such as `example.com`, and a SAN is a wildcard, such as `*.example.com`. The CN stays the domain (CERTInext requires the domain to match the CSR CN, `EMS-1056`), and the wildcard is sent in `additionalDomains`. On some accounts CERTInext rejects this shape with `EMS-1173 Invalid Additional Domain Names`; if it does, set `ProductCode` on the template to the account's Wildcard UCC product code. 2. **Explicit `ProductCode` (or the deprecated `ProfileId` alias)** — the override. It is sent as-is in the `X-Product-Code` header. CERTInext advises against sending it, so use it only when your account holds several matching products (for example different CA profiles for the same variant) and you want to force one. The plugin doesn't check the code against the catalog, either when the template is saved or at enrollment. It decides wildcard and multi-domain from the request the same way as without an override, and CERTInext rejects a code that doesn't exist or can't carry the request. This differs from V1, where `DefaultProductCode` only affects renewals (see [DefaultProductCode](#defaultproductcode)). From 5d0617c7e9c588dc01e34e8e540954c95ac235f2 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 17 Nov 2026 20:03:27 +0000 Subject: [PATCH 12/12] docs: auto-generate README and documentation [skip ci] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9f26251..2391acb 100644 --- a/README.md +++ b/README.md @@ -634,7 +634,7 @@ CERTInext advises sending only the variant and leaving `X-Product-Code` out, so - **Wildcard:** the primary domain starts with `*.`. - **Multi-domain:** the selected product is a UCC product, or the gateway's SAN list carries DNS names beyond the primary domain (its `www.` variant, and a wildcard's bare apex, don't count). Those names are sent as `additionalDomains`, which makes CERTInext choose a UCC product. - **SAN source:** Command's SAN list (passed by the gateway) is authoritative. A DNS name that is only in the CSR doesn't make the order multi-domain and isn't sent in `additionalDomains`; the CSR itself is still sent to CERTInext unchanged. The CSR's SANs are used only when the gateway passes no SAN list at all. This matches the other Keyfactor CA plugins that build a SAN list for their CA. - - **Wildcard in the SANs only:** the CN is a plain name, such as `example.com`, and a SAN is a wildcard, such as `*.example.com`. The CN stays the domain (CERTInext requires the domain to match the CSR CN, `EMS-1056`), and the wildcard is sent in `additionalDomains`. On some accounts CERTInext rejects this shape with `EMS-1173 Invalid Additional Domain Names` (seen on an emSign-backed sandbox account); if it does, set `ProductCode` on the template to the account's Wildcard UCC product code. + - **Wildcard in the SANs only:** the CN is a plain name, such as `example.com`, and a SAN is a wildcard, such as `*.example.com`. The CN stays the domain (CERTInext requires the domain to match the CSR CN, `EMS-1056`), and the wildcard is sent in `additionalDomains`. On some accounts CERTInext rejects this shape with `EMS-1173 Invalid Additional Domain Names`; if it does, set `ProductCode` on the template to the account's Wildcard UCC product code. 2. **Explicit `ProductCode` (or the deprecated `ProfileId` alias)** — the override. It is sent as-is in the `X-Product-Code` header. CERTInext advises against sending it, so use it only when your account holds several matching products (for example different CA profiles for the same variant) and you want to force one. The plugin doesn't check the code against the catalog, either when the template is saved or at enrollment. It decides wildcard and multi-domain from the request the same way as without an override, and CERTInext rejects a code that doesn't exist or can't carry the request. This differs from V1, where `DefaultProductCode` only affects renewals (see [DefaultProductCode](#defaultproductcode)).