Project

General

Profile

Bug #13424 ยป 13424.diff

Jim Pingle, 08/17/2022 11:11 AM

View differences:

src/etc/inc/certs.inc
54 54
global $cert_max_lifetime;
55 55
$cert_max_lifetime = 12000;
56 56

  
57
global $crl_max_lifetime;
58
$crl_max_lifetime = 9999;
59

  
57 60
function & lookup_ca($refid) {
58 61
	global $config;
59 62

  
......
978 981
	return min($max, $cert_max_lifetime);
979 982
}
980 983

  
984
/* Detect a rollover at 2050 with UTCTime
985
 * See: https://redmine.pfsense.org/issues/9098 */
986
function crl_get_max_lifetime() {
987
	global $crl_max_lifetime;
988
	$max = $crl_max_lifetime;
989

  
990
	$now = new DateTime("now");
991
	$utctime_before_roll = DateTime::createFromFormat('Ymd', '20491231');
992
	if ($date !== false) {
993
		$interval = $now->diff($utctime_before_roll);
994
		$max_days = abs($interval->days);
995
		/* Reduce the max well below the rollover time */
996
		if ($max_days > 1000) {
997
			$max_days -= 1000;
998
		}
999
		return min($max_days, cert_get_max_lifetime());
1000
	}
1001

  
1002
	/* Cannot use date functions, so use a lower default max. */
1003
	return min(7000, cert_get_max_lifetime());
1004
}
1005

  
981 1006
function crl_create(& $crl, $caref, $name, $serial = 0, $lifetime = 3650) {
982 1007
	global $config;
983
	$max_lifetime = cert_get_max_lifetime();
1008
	$max_lifetime = crl_get_max_lifetime();
984 1009
	$ca =& lookup_ca($caref);
985 1010
	if (!$ca) {
986 1011
		return false;
......
1017 1042
	require_once('X509_CRL.php');
1018 1043

  
1019 1044
	global $config;
1020
	$max_lifetime = cert_get_max_lifetime();
1045
	$max_lifetime = crl_get_max_lifetime();
1021 1046
	$ca =& lookup_ca($crl['caref']);
1022 1047
	if (!$ca) {
1023 1048
		return false;
src/usr/local/www/system_crlmanager.php
34 34
require_once("pfsense-utils.inc");
35 35
require_once("vpn.inc");
36 36

  
37
$max_lifetime = cert_get_max_lifetime();
38
$default_lifetime = min(9999, $max_lifetime);
37
$max_lifetime = crl_get_max_lifetime();
38
$default_lifetime = min(730, $max_lifetime);
39 39

  
40 40
global $openssl_crl_status;
41 41

  
......
255 255
		}
256 256

  
257 257
		if ($pconfig['method'] == "internal") {
258
			$crl['serial'] = empty($pconfig['serial']) ? 9999 : $pconfig['serial'];
258
			$crl['serial'] = empty($pconfig['serial']) ? '0' : $pconfig['serial'];
259 259
			$crl['lifetime'] = empty($pconfig['lifetime']) ? $default_lifetime : $pconfig['lifetime'];
260 260
			$crl['cert'] = array();
261 261
		}
    (1-1/1)