CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-certbot-nginx

Nginx plugin for Certbot that enables automated SSL/TLS certificate management and deployment for Nginx web servers.

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

display-ops.mddocs/

Display Operations

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.

Capabilities

Virtual Host Selection Interface

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
    """

Usage Examples

Interactive Virtual Host Selection

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_vhosts

Integration with Configurator

from 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}")

User Interface Behavior

The select_vhost_multiple function provides:

  1. Clear Options Display: Shows virtual host details including:

    • File path and location
    • Server names and aliases
    • Listen addresses and ports
    • SSL configuration status
  2. Multiple Selection: Allows users to select multiple virtual hosts for batch certificate installation

  3. Validation: Ensures at least one virtual host is selected before proceeding

  4. Error Handling: Provides clear error messages for invalid selections

Integration Points

Display operations integrate with:

  • NginxConfigurator: Called when virtual host selection is ambiguous
  • Certificate Deployment: Used before deploying certificates to multiple hosts
  • Enhancement Application: Used when applying enhancements to multiple virtual hosts
  • Challenge Configuration: Used when setting up challenges across multiple hosts

Error Handling

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 cancellation

The 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

docs

configurator.md

constants.md

display-ops.md

http-01.md

index.md

nginxparser.md

objects.md

parser.md

tile.json