Bug #3733 » certmanager_san_wildcard_hostname.patch
| etc/inc/util.inc | ||
|---|---|---|
|
}
|
||
|
/* returns true if $hostname is a valid hostname, with or without being a fully-qualified domain name. */
|
||
|
function is_hostname($hostname) {
|
||
|
function is_hostname($hostname, $allow_wildcard=false) {
|
||
|
if (!is_string($hostname)) {
|
||
|
return false;
|
||
|
}
|
||
|
if (is_domain($hostname)) {
|
||
|
if (is_domain($hostname, $allow_wildcard)) {
|
||
|
if ((substr_count($hostname, ".") == 1) && ($hostname[strlen($hostname)-1] == ".")) {
|
||
|
/* Only a single dot at the end like "test." - hosts cannot be directly in the root domain. */
|
||
|
return false;
|
||
| ... | ... | |
|
}
|
||
|
/* returns true if $domain is a valid domain name */
|
||
|
function is_domain($domain) {
|
||
|
function is_domain($domain, $allow_wildcard=false) {
|
||
|
if (!is_string($domain)) {
|
||
|
return false;
|
||
|
}
|
||
|
if (preg_match('/^(?:(?:[a-z_0-9]|[a-z_0-9][a-z_0-9\-]*[a-z_0-9])\.)*(?:[a-z_0-9]|[a-z_0-9][a-z_0-9\-]*[a-z_0-9\.])$/i', $domain)) {
|
||
|
$domain_regex = ($allow_wildcard) ? '/^(?:(?:[a-z_0-9\*]|[a-z_0-9][a-z_0-9\-]*[a-z_0-9])\.)*(?:[a-z_0-9]|[a-z_0-9][a-z_0-9\-]*[a-z_0-9\.])$/i' : '/^(?:(?:[a-z_0-9]|[a-z_0-9][a-z_0-9\-]*[a-z_0-9])\.)*(?:[a-z_0-9]|[a-z_0-9][a-z_0-9\-]*[a-z_0-9\.])$/i';
|
||
|
if (preg_match($domain_regex, $domain)) {
|
||
|
return true;
|
||
|
} else {
|
||
|
return false;
|
||
| usr/local/www/system_certmanager.php | ||
|---|---|---|
|
foreach ($altnames as $idx => $altname) {
|
||
|
switch ($altname['type']) {
|
||
|
case "DNS":
|
||
|
if (!is_hostname($altname['value'])) {
|
||
|
array_push($input_errors, "DNS subjectAltName values must be valid hostnames or FQDNs");
|
||
|
if (!is_hostname($altname['value'], true)) {
|
||
|
array_push($input_errors, "DNS subjectAltName values must be valid hostnames, FQDNs or wildcard domains.");
|
||
|
}
|
||
|
break;
|
||
|
case "IP":
|
||
- « Previous
- 1
- 2
- 3
- Next »