Skip to content

CBL-7011: Cannot access the kCBLCertAttrKeyLocality value from the ce… #2285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion C/include/c4CertificateTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ typedef C4Slice C4CertNameAttributeID;
# define kC4Cert_Organization C4STR("O") // e.g. "Example Corp."
# define kC4Cert_OrganizationUnit C4STR("OU") // e.g. "Marketing"
# define kC4Cert_PostalAddress C4STR("postalAddress") // e.g. "123 Example Blvd #2A"
# define kC4Cert_Locality C4STR("locality") // e.g. "Boston"
# define kC4Cert_Locality C4STR("L") // e.g. "Boston"
# define kC4Cert_PostalCode C4STR("postalCode") // e.g. "02134"
# define kC4Cert_StateOrProvince C4STR("ST") // e.g. "Massachusetts" (or "Quebec", ...)
# define kC4Cert_Country C4STR("C") // e.g. "us" (2-letter ISO country code)
Expand Down
40 changes: 39 additions & 1 deletion C/tests/c4CertificateTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,43 @@ TEST_CASE("C4Certificate smoke test", "[Certs][C]") {
}
}

TEST_CASE("C4Certificate Subject Name", "[Certs][C]") {
C4CertNameComponent nameComponents[] = {{kC4Cert_CommonName, "CommonName"_sl},
{kC4Cert_Pseudonym, "Pseudonym"_sl},
{kC4Cert_GivenName, "GivenName"_sl},
{kC4Cert_Surname, "Surname"_sl},
{kC4Cert_Organization, "Organiztion"_sl},
{kC4Cert_OrganizationUnit, "OrganizationUnit"_sl},
{kC4Cert_PostalAddress, "PostalAddress"_sl},
{kC4Cert_Locality, "Locality"_sl},
{kC4Cert_PostalCode, "PostalCode"_sl},
{kC4Cert_StateOrProvince, "StateOrProvince"_sl},
{kC4Cert_Country, "Country"_sl},
{kC4Cert_EmailAddress, "EmailAddress"_sl},
{kC4Cert_Hostname, "Hostname"_sl},
{kC4Cert_URL, "URL"_sl},
{kC4Cert_IPAddress, "IPAddress"_sl},
{kC4Cert_RegisteredID, "RegisteredID"_sl}};
size_t compCount = std::size(nameComponents);

#endif
c4::ref<C4Cert> cert = [&]() -> C4Cert* {
c4::ref<C4KeyPair> key = c4keypair_generate(kC4RSA, 2048, false, nullptr);
REQUIRE(key);

c4::ref<C4Cert> csr = c4cert_createRequest(nameComponents, compCount, kC4CertUsage_TLSClient, key, nullptr);
REQUIRE(csr);

C4CertIssuerParameters issuerParams = kDefaultCertIssuerParameters;
issuerParams.validityInSeconds = 3600;
issuerParams.isCA = false;
return c4cert_signRequest(csr, &issuerParams, key, nullptr, nullptr);
}();
REQUIRE(cert);

for ( size_t i = 0; i < compCount; ++i ) {
alloc_slice nameComp = c4cert_subjectNameComponent(cert, nameComponents[i].attributeID);
CHECK(nameComp == nameComponents[i].value);
}
}

#endif //#ifdef COUCHBASE_ENTERPRISE
2 changes: 1 addition & 1 deletion Replicator/ChangesFeed.cc
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ namespace litecore::repl {
bool ChangesFeed::shouldPushRev(RevToSend* rev, C4DocEnumerator* e) const {
bool needRemoteRevID = _getForeignAncestors && !rev->remoteAncestorRevID && _isCheckpointValid;
if ( needRemoteRevID || _options->pushFilter(_collectionIndex) ) {
C4Error error;
C4Error error{};
Retained<C4Document> doc;
try {
_db.useLocked([&](C4Database* db) {
Expand Down
Loading