add SSL and mSSL support
This commit is contained in:
		
							parent
							
								
									f8258117f4
								
							
						
					
					
						commit
						42760490b9
					
				
					 3 changed files with 20 additions and 4 deletions
				
			
		
							
								
								
									
										2
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -141,3 +141,5 @@ cython_debug/
 | 
			
		|||
# Project specific:
 | 
			
		||||
.sync_token
 | 
			
		||||
config.yaml
 | 
			
		||||
*.key
 | 
			
		||||
*.crt
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -29,11 +29,11 @@ class Config:
 | 
			
		|||
        """
 | 
			
		||||
        if self.tls_auth and not self.tls:
 | 
			
		||||
            raise ValueError("tls_auth is enable, but not tls.")
 | 
			
		||||
        if self.tls and tls_crt is None:
 | 
			
		||||
        if self.tls and self.tls_crt is None:
 | 
			
		||||
            raise ValueError("tls is enable but tls_crt was not provided")
 | 
			
		||||
        if self.tls and tls_key is None:
 | 
			
		||||
        if self.tls and self.tls_key is None:
 | 
			
		||||
            raise ValueError("tls is enable but tls_key was not provided")
 | 
			
		||||
        if self.tls_auth and ca_cert is None:
 | 
			
		||||
        if self.tls_auth and self.ca_crt is None:
 | 
			
		||||
            raise ValueError("tls_auth is enable, but ca_crt was not provided")
 | 
			
		||||
        return True
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -14,7 +14,21 @@ from typing import (
 | 
			
		|||
from .config import Config
 | 
			
		||||
 | 
			
		||||
def load_ssl_context(config:Config)->ssl.SSLContext:
 | 
			
		||||
    pass
 | 
			
		||||
    """
 | 
			
		||||
        Load the SSL context from the config.
 | 
			
		||||
    """
 | 
			
		||||
    ca_path = None
 | 
			
		||||
    if config.tls_auth:
 | 
			
		||||
        ca_path = config.ca_crt
 | 
			
		||||
    ssl_context = ssl.create_default_context(
 | 
			
		||||
        purpose=ssl.Purpose.CLIENT_AUTH,
 | 
			
		||||
        cafile=ca_path
 | 
			
		||||
    )
 | 
			
		||||
    if config.tls_auth:
 | 
			
		||||
        ssl_context.verify_mode = ssl.CERT_REQUIRED
 | 
			
		||||
    ssl_context.load_cert_chain(config.tls_crt, config.tls_key)
 | 
			
		||||
    return ssl_context
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
async def run_webhook(
 | 
			
		||||
    alert_queue: asyncio.Queue[dict[str, Any]],
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue