mikrotik check cert
This commit is contained in:
		| @@ -626,56 +626,56 @@ class CertPusher: | ||||
|         return cert_path.replace('fullchain.pem', 'privkey.pem').replace('cert.pem', 'privkey.pem') | ||||
|      | ||||
|     def process_mikrotik(self, section: str, hostname: str, port: int, username: str, ssh_key: str, source_cert_path: str) -> bool: | ||||
|     """Process MikroTik device""" | ||||
|     try: | ||||
|         source_key_path = self.get_key_path(section, source_cert_path) | ||||
|          | ||||
|         if not os.path.exists(source_key_path): | ||||
|             logger.error(f"Key not found: {source_key_path}") | ||||
|             return False | ||||
|          | ||||
|         source_cert = self.cert_manager.get_cert_from_file(source_cert_path) | ||||
|         if not source_cert: | ||||
|             return False | ||||
|          | ||||
|         check_first = self.config.getboolean(section, 'check_before_upload', fallback=True) | ||||
|          | ||||
|         # Get services to configure (default: www-ssl) | ||||
|         services_str = self.config.get(section, 'mikrotik_services', fallback='www-ssl') | ||||
|         services = [s.strip() for s in services_str.split(',')] | ||||
|          | ||||
|         logger.info(f"Target services: {', '.join(services)}") | ||||
|          | ||||
|         mikrotik = MikroTikManager(hostname, port, username, ssh_key) | ||||
|          | ||||
|         if not mikrotik.connect(): | ||||
|             self.stats['failed'] += 1 | ||||
|             return False | ||||
|          | ||||
|         success, was_uploaded = mikrotik.upload_certificate( | ||||
|             source_cert_path,  | ||||
|             source_key_path,  | ||||
|             check_first,  | ||||
|             source_cert, | ||||
|             services  # Pass services list | ||||
|         ) | ||||
|         mikrotik.disconnect() | ||||
|          | ||||
|         if success: | ||||
|             if was_uploaded: | ||||
|                 self.stats['uploaded'] += 1 | ||||
|         """Process MikroTik device""" | ||||
|         try: | ||||
|             source_key_path = self.get_key_path(section, source_cert_path) | ||||
|              | ||||
|             if not os.path.exists(source_key_path): | ||||
|                 logger.error(f"Key not found: {source_key_path}") | ||||
|                 return False | ||||
|              | ||||
|             source_cert = self.cert_manager.get_cert_from_file(source_cert_path) | ||||
|             if not source_cert: | ||||
|                 return False | ||||
|              | ||||
|             check_first = self.config.getboolean(section, 'check_before_upload', fallback=True) | ||||
|              | ||||
|             # Get services to configure (default: www-ssl) | ||||
|             services_str = self.config.get(section, 'mikrotik_services', fallback='www-ssl') | ||||
|             services = [s.strip() for s in services_str.split(',')] | ||||
|              | ||||
|             logger.info(f"Target services: {', '.join(services)}") | ||||
|              | ||||
|             mikrotik = MikroTikManager(hostname, port, username, ssh_key) | ||||
|              | ||||
|             if not mikrotik.connect(): | ||||
|                 self.stats['failed'] += 1 | ||||
|                 return False | ||||
|              | ||||
|             success, was_uploaded = mikrotik.upload_certificate( | ||||
|                 source_cert_path,  | ||||
|                 source_key_path,  | ||||
|                 check_first,  | ||||
|                 source_cert, | ||||
|                 services  # Pass services list | ||||
|             ) | ||||
|             mikrotik.disconnect() | ||||
|              | ||||
|             if success: | ||||
|                 if was_uploaded: | ||||
|                     self.stats['uploaded'] += 1 | ||||
|                 else: | ||||
|                     self.stats['skipped'] += 1 | ||||
|                 logger.info("✓ MikroTik processed") | ||||
|                 return True | ||||
|             else: | ||||
|                 self.stats['skipped'] += 1 | ||||
|             logger.info("✓ MikroTik processed") | ||||
|             return True | ||||
|         else: | ||||
|                 self.stats['failed'] += 1 | ||||
|                 return False | ||||
|              | ||||
|         except Exception as e: | ||||
|             logger.error(f"MikroTik failed: {e}") | ||||
|             self.stats['failed'] += 1 | ||||
|             return False | ||||
|          | ||||
|     except Exception as e: | ||||
|         logger.error(f"MikroTik failed: {e}") | ||||
|         self.stats['failed'] += 1 | ||||
|         return False | ||||
|  | ||||
|      | ||||
|     def process_proxmox(self, section: str, hostname: str, port: int, username: str, ssh_key: str, source_cert_path: str) -> bool: | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Mateusz Gruszczyński
					Mateusz Gruszczyński