Requests_SSL::verify_reference_name() WordPress Method
The verify_reference_name() method is used to verify that the given name is a valid reference name for an SSL certificate. This is useful for ensuring that a given name can be used to reference a specific certificate when using the SSL API.
Requests_SSL::verify_reference_name( string $reference ) #
Verify that a reference name is valid
Description
Verifies a dNSName for HTTPS usage, (almost) as per Firefox’s rules:
- Wildcards can only occur in a name with more than 3 components
- Wildcards can only occur as the last character in the first component
- Wildcards may be preceded by additional characters
We modify these rules to be a bit stricter and only allow the wildcard character to be the full first component; that is, with the exclusion of the third rule.
Parameters
- $reference
(string)(Required)Reference dNSName
Return
(boolean) Is the name valid?
Source
File: wp-includes/Requests/SSL.php
public static function verify_reference_name($reference) { $parts = explode('.', $reference); // Check the first part of the name $first = array_shift($parts); if (strpos($first, '*') !== false) { // Check that the wildcard is the full part if ($first !== '*') { return false; } // Check that we have at least 3 components (including first) if (count($parts) < 2) { return false; } } // Check the remaining parts foreach ($parts as $part) { if (strpos($part, '*') !== false) { return false; } } // Nothing found, verified! return true; }
Expand full source codeCollapse full source codeView on TracView on GitHub