mirror of
				https://github.com/mail-in-a-box/mailinabox.git
				synced 2025-11-03 19:30:54 +00:00 
			
		
		
		
	Update to latest cryptography Python package, add missing source at top of management.sh so it can run standalone (needs STORAGE_ROOT)
This commit is contained in:
		
							parent
							
								
									87e6df9e28
								
							
						
					
					
						commit
						ab71abbc7c
					
				@ -58,36 +58,33 @@ def get_ssl_certificates(env):
 | 
				
			|||||||
			# Not a valid PEM format for a PEM type we care about.
 | 
								# Not a valid PEM format for a PEM type we care about.
 | 
				
			||||||
			continue
 | 
								continue
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		# Remember where we got this object.
 | 
					 | 
				
			||||||
		pem._filename = fn
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		# Is it a private key?
 | 
							# Is it a private key?
 | 
				
			||||||
		if isinstance(pem, RSAPrivateKey):
 | 
							if isinstance(pem, RSAPrivateKey):
 | 
				
			||||||
			private_keys[pem.public_key().public_numbers()] = pem
 | 
								private_keys[pem.public_key().public_numbers()] = { "filename": fn, "key": pem }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		# Is it a certificate?
 | 
							# Is it a certificate?
 | 
				
			||||||
		if isinstance(pem, Certificate):
 | 
							if isinstance(pem, Certificate):
 | 
				
			||||||
			certificates.append(pem)
 | 
								certificates.append({ "filename": fn, "cert": pem })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	# Process the certificates.
 | 
						# Process the certificates.
 | 
				
			||||||
	domains = { }
 | 
						domains = { }
 | 
				
			||||||
	for cert in certificates:
 | 
						for cert in certificates:
 | 
				
			||||||
		# What domains is this certificate good for?
 | 
							# What domains is this certificate good for?
 | 
				
			||||||
		cert_domains, primary_domain = get_certificate_domains(cert)
 | 
							cert_domains, primary_domain = get_certificate_domains(cert["cert"])
 | 
				
			||||||
		cert._primary_domain = primary_domain
 | 
							cert["primary_domain"] = primary_domain
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		# Is there a private key file for this certificate?
 | 
							# Is there a private key file for this certificate?
 | 
				
			||||||
		private_key = private_keys.get(cert.public_key().public_numbers())
 | 
							private_key = private_keys.get(cert["cert"].public_key().public_numbers())
 | 
				
			||||||
		if not private_key:
 | 
							if not private_key:
 | 
				
			||||||
			continue
 | 
								continue
 | 
				
			||||||
		cert._private_key = private_key
 | 
							cert["private_key"] = private_key
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		# Add this cert to the list of certs usable for the domains.
 | 
							# Add this cert to the list of certs usable for the domains.
 | 
				
			||||||
		for domain in cert_domains:
 | 
							for domain in cert_domains:
 | 
				
			||||||
			# The primary hostname can only use a certificate mapped
 | 
								# The primary hostname can only use a certificate mapped
 | 
				
			||||||
			# to the system private key.
 | 
								# to the system private key.
 | 
				
			||||||
			if domain == env['PRIMARY_HOSTNAME']:
 | 
								if domain == env['PRIMARY_HOSTNAME']:
 | 
				
			||||||
				if cert._private_key._filename != os.path.join(env['STORAGE_ROOT'], 'ssl', 'ssl_private_key.pem'):
 | 
									if cert["private_key"]["filename"] != os.path.join(env['STORAGE_ROOT'], 'ssl', 'ssl_private_key.pem'):
 | 
				
			||||||
					continue
 | 
										continue
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			domains.setdefault(domain, []).append(cert)
 | 
								domains.setdefault(domain, []).append(cert)
 | 
				
			||||||
@ -100,10 +97,10 @@ def get_ssl_certificates(env):
 | 
				
			|||||||
		#for c in cert_list: print(domain, c.not_valid_before, c.not_valid_after, "("+str(now)+")", c.issuer, c.subject, c._filename)
 | 
							#for c in cert_list: print(domain, c.not_valid_before, c.not_valid_after, "("+str(now)+")", c.issuer, c.subject, c._filename)
 | 
				
			||||||
		cert_list.sort(key = lambda cert : (
 | 
							cert_list.sort(key = lambda cert : (
 | 
				
			||||||
			# must be valid NOW
 | 
								# must be valid NOW
 | 
				
			||||||
			cert.not_valid_before <= now <= cert.not_valid_after,
 | 
								cert["cert"].not_valid_before <= now <= cert["cert"].not_valid_after,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			# prefer one that is not self-signed
 | 
								# prefer one that is not self-signed
 | 
				
			||||||
			cert.issuer != cert.subject,
 | 
								cert["cert"].issuer != cert["cert"].subject,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			###########################################################
 | 
								###########################################################
 | 
				
			||||||
			# The above lines ensure that valid certificates are chosen
 | 
								# The above lines ensure that valid certificates are chosen
 | 
				
			||||||
@ -113,7 +110,7 @@ def get_ssl_certificates(env):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			# prefer one with the expiration furthest into the future so
 | 
								# prefer one with the expiration furthest into the future so
 | 
				
			||||||
			# that we can easily rotate to new certs as we get them
 | 
								# that we can easily rotate to new certs as we get them
 | 
				
			||||||
			cert.not_valid_after,
 | 
								cert["cert"].not_valid_after,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			###########################################################
 | 
								###########################################################
 | 
				
			||||||
			# We always choose the certificate that is good for the
 | 
								# We always choose the certificate that is good for the
 | 
				
			||||||
@ -128,15 +125,15 @@ def get_ssl_certificates(env):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			# in case a certificate is installed in multiple paths,
 | 
								# in case a certificate is installed in multiple paths,
 | 
				
			||||||
			# prefer the... lexicographically last one?
 | 
								# prefer the... lexicographically last one?
 | 
				
			||||||
			cert._filename,
 | 
								cert["filename"],
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		), reverse=True)
 | 
							), reverse=True)
 | 
				
			||||||
		cert = cert_list.pop(0)
 | 
							cert = cert_list.pop(0)
 | 
				
			||||||
		ret[domain] = {
 | 
							ret[domain] = {
 | 
				
			||||||
			"private-key": cert._private_key._filename,
 | 
								"private-key": cert["private_key"]["filename"],
 | 
				
			||||||
			"certificate": cert._filename,
 | 
								"certificate": cert["filename"],
 | 
				
			||||||
			"primary-domain": cert._primary_domain,
 | 
								"primary-domain": cert["primary_domain"],
 | 
				
			||||||
			"certificate_object": cert,
 | 
								"certificate_object": cert["cert"],
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return ret
 | 
						return ret
 | 
				
			||||||
 | 
				
			|||||||
@ -1,6 +1,7 @@
 | 
				
			|||||||
#!/bin/bash
 | 
					#!/bin/bash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
source setup/functions.sh
 | 
					source setup/functions.sh
 | 
				
			||||||
 | 
					source /etc/mailinabox.conf # load global vars
 | 
				
			||||||
 | 
					
 | 
				
			||||||
echo "Installing Mail-in-a-Box system management daemon..."
 | 
					echo "Installing Mail-in-a-Box system management daemon..."
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -51,7 +52,7 @@ hide_output $venv/bin/pip install --upgrade \
 | 
				
			|||||||
	rtyaml "email_validator>=1.0.0" "exclusiveprocess" \
 | 
						rtyaml "email_validator>=1.0.0" "exclusiveprocess" \
 | 
				
			||||||
	flask dnspython python-dateutil expiringdict \
 | 
						flask dnspython python-dateutil expiringdict \
 | 
				
			||||||
	qrcode[pil] pyotp \
 | 
						qrcode[pil] pyotp \
 | 
				
			||||||
	"idna>=2.0.0" "cryptography==2.2.2" psutil postfix-mta-sts-resolver \
 | 
						"idna>=2.0.0" "cryptography==37.0.2" psutil postfix-mta-sts-resolver \
 | 
				
			||||||
	b2sdk boto
 | 
						b2sdk boto
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# CONFIGURATION
 | 
					# CONFIGURATION
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user