Skip to content
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

Modularizes and creates UTs for certificate validation functions #492

Conversation

Nicogp
Copy link
Member

@Nicogp Nicogp commented Jan 9, 2025

Related issue
#477

Description

This PR adds changes to modularize the certificate validation functions, it also creates a wrapper for external function calls.
It also adds UTs for new certificate validation methods.

Tests

  • Compilation without warnings in every supported platform
    • Linux
    • Windows
    • MAC OS X

@Nicogp Nicogp linked an issue Jan 9, 2025 that may be closed by this pull request
@Nicogp Nicogp force-pushed the enhancement/477-create-unit-tests-for-certificate-validation-functions branch from cdf7fe0 to 1879a6d Compare January 9, 2025 14:41
@Nicogp Nicogp force-pushed the enhancement/477-create-unit-tests-for-certificate-validation-functions branch 6 times, most recently from 6f47288 to 87060ad Compare January 14, 2025 20:42
// Release the CFStringRef if it was created
if (cfHostname)
{
CFRelease(cfHostname);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a deleter here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think not, cfHostname is the one that is released and policy is the one that is returned.

SecPolicyRef CreateSSLPolicy(bool server, const std::string& hostname) const override
        {
            // Convert std::string to CFStringRef
            CFStringRef cfHostname =
                hostname.empty()
                    ? nullptr
                    : CFStringCreateWithCString(kCFAllocatorDefault, hostname.c_str(), kCFStringEncodingUTF8);

            // Call SecPolicyCreateSSL with the CFStringRef hostname
            SecPolicyRef policy = SecPolicyCreateSSL(server, cfHostname);

            // Release the CFStringRef if it was created
            if (cfHostname)
            {
                CFRelease(cfHostname);
            }

            return policy;
        }

@Nicogp Nicogp force-pushed the enhancement/477-create-unit-tests-for-certificate-validation-functions branch 12 times, most recently from de96d90 to 78bff28 Compare January 20, 2025 18:18
@Nicogp Nicogp force-pushed the enhancement/477-create-unit-tests-for-certificate-validation-functions branch from 541c719 to 8f9c83b Compare January 21, 2025 02:01
Nicogp added 16 commits January 21, 2025 18:50
… to wrap the call to external functions in the validation of the certification (and its respective abstract class).
…cert_store_utils_mac and cert_store_utils_win
…HttpsVerifierMac. Adds a check for certificate utility pointers.
@Nicogp Nicogp force-pushed the enhancement/477-create-unit-tests-for-certificate-validation-functions branch from 792d49a to 9a14297 Compare January 21, 2025 21:57
@Nicogp Nicogp marked this pull request as ready for review January 22, 2025 02:58
TomasTurina

This comment was marked as resolved.

@TomasTurina TomasTurina merged commit 7facee7 into master Jan 22, 2025
5 checks passed
@TomasTurina TomasTurina deleted the enhancement/477-create-unit-tests-for-certificate-validation-functions branch January 22, 2025 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create unit tests for certificate validation functions
2 participants