Nginx plugin for Certbot that enables automated SSL/TLS certificate management and deployment for Nginx web servers.
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
User interface operations for interactive virtual host selection and management. These functions provide the interactive components needed when multiple virtual hosts match a domain or when user input is required.
Interactive selection interface for choosing from multiple virtual host options.
def select_vhost_multiple(vhosts: Optional[Iterable[VirtualHost]]) -> list[VirtualHost]:
"""Select multiple virtual hosts for certificate installation.
Presents an interactive interface allowing users to select which virtual hosts
should receive certificate installation when multiple options are available.
Used when domain matching returns multiple potential targets.
Args:
vhosts: Available virtual hosts to choose from
Returns:
List of VirtualHost objects selected by user for certificate installation
Raises:
errors.PluginError: If no virtual hosts are provided or selection fails
"""from certbot_nginx._internal.display_ops import select_vhost_multiple
from certbot_nginx._internal.parser import NginxParser
# Initialize parser and get virtual hosts
parser = NginxParser('/etc/nginx')
parser.load()
all_vhosts = parser.get_vhosts()
# Filter virtual hosts matching domain
domain = "example.com"
matching_vhosts = [vhost for vhost in all_vhosts
if domain in vhost.names or
any(domain in name for name in vhost.names)]
if len(matching_vhosts) > 1:
# Present selection interface to user
selected_vhosts = select_vhost_multiple(matching_vhosts)
print(f"User selected {len(selected_vhosts)} virtual hosts")
for vhost in selected_vhosts:
print(f"Selected: {vhost.display_repr()}")
else:
# Single match or no matches - no selection needed
selected_vhosts = matching_vhostsfrom certbot_nginx._internal.configurator import NginxConfigurator
from certbot_nginx._internal.display_ops import select_vhost_multiple
# When configurator finds multiple matches
configurator = NginxConfigurator(config, name='nginx')
configurator.prepare()
# Get candidates for certificate installation
candidates = configurator.choose_vhosts('example.com')
if len(candidates) > 1:
# Let user choose which ones to use
selected = select_vhost_multiple(candidates)
# Deploy certificates to selected virtual hosts
for vhost in selected:
# Deploy certificate logic here
print(f"Deploying certificate to {vhost.filep}")The select_vhost_multiple function provides:
Clear Options Display: Shows virtual host details including:
Multiple Selection: Allows users to select multiple virtual hosts for batch certificate installation
Validation: Ensures at least one virtual host is selected before proceeding
Error Handling: Provides clear error messages for invalid selections
Display operations integrate with:
from certbot import errors
try:
selected_vhosts = select_vhost_multiple(candidates)
except errors.PluginError as e:
print(f"Selection failed: {e}")
# Handle selection failure
except KeyboardInterrupt:
print("Selection cancelled by user")
# Handle user cancellationThe display operations module ensures a smooth user experience when the nginx plugin encounters situations requiring user input or clarification.
Install with Tessl CLI
npx tessl i tessl/pypi-certbot-nginx