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') |         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: |     def process_mikrotik(self, section: str, hostname: str, port: int, username: str, ssh_key: str, source_cert_path: str) -> bool: | ||||||
|     """Process MikroTik device""" |         """Process MikroTik device""" | ||||||
|     try: |         try: | ||||||
|         source_key_path = self.get_key_path(section, source_cert_path) |             source_key_path = self.get_key_path(section, source_cert_path) | ||||||
|          |              | ||||||
|         if not os.path.exists(source_key_path): |             if not os.path.exists(source_key_path): | ||||||
|             logger.error(f"Key not found: {source_key_path}") |                 logger.error(f"Key not found: {source_key_path}") | ||||||
|             return False |                 return False | ||||||
|          |              | ||||||
|         source_cert = self.cert_manager.get_cert_from_file(source_cert_path) |             source_cert = self.cert_manager.get_cert_from_file(source_cert_path) | ||||||
|         if not source_cert: |             if not source_cert: | ||||||
|             return False |                 return False | ||||||
|          |              | ||||||
|         check_first = self.config.getboolean(section, 'check_before_upload', fallback=True) |             check_first = self.config.getboolean(section, 'check_before_upload', fallback=True) | ||||||
|          |              | ||||||
|         # Get services to configure (default: www-ssl) |             # Get services to configure (default: www-ssl) | ||||||
|         services_str = self.config.get(section, 'mikrotik_services', fallback='www-ssl') |             services_str = self.config.get(section, 'mikrotik_services', fallback='www-ssl') | ||||||
|         services = [s.strip() for s in services_str.split(',')] |             services = [s.strip() for s in services_str.split(',')] | ||||||
|          |              | ||||||
|         logger.info(f"Target services: {', '.join(services)}") |             logger.info(f"Target services: {', '.join(services)}") | ||||||
|          |              | ||||||
|         mikrotik = MikroTikManager(hostname, port, username, ssh_key) |             mikrotik = MikroTikManager(hostname, port, username, ssh_key) | ||||||
|          |              | ||||||
|         if not mikrotik.connect(): |             if not mikrotik.connect(): | ||||||
|             self.stats['failed'] += 1 |                 self.stats['failed'] += 1 | ||||||
|             return False |                 return False | ||||||
|          |              | ||||||
|         success, was_uploaded = mikrotik.upload_certificate( |             success, was_uploaded = mikrotik.upload_certificate( | ||||||
|             source_cert_path,  |                 source_cert_path,  | ||||||
|             source_key_path,  |                 source_key_path,  | ||||||
|             check_first,  |                 check_first,  | ||||||
|             source_cert, |                 source_cert, | ||||||
|             services  # Pass services list |                 services  # Pass services list | ||||||
|         ) |             ) | ||||||
|         mikrotik.disconnect() |             mikrotik.disconnect() | ||||||
|          |              | ||||||
|         if success: |             if success: | ||||||
|             if was_uploaded: |                 if was_uploaded: | ||||||
|                 self.stats['uploaded'] += 1 |                     self.stats['uploaded'] += 1 | ||||||
|  |                 else: | ||||||
|  |                     self.stats['skipped'] += 1 | ||||||
|  |                 logger.info("✓ MikroTik processed") | ||||||
|  |                 return True | ||||||
|             else: |             else: | ||||||
|                 self.stats['skipped'] += 1 |                 self.stats['failed'] += 1 | ||||||
|             logger.info("✓ MikroTik processed") |                 return False | ||||||
|             return True |              | ||||||
|         else: |         except Exception as e: | ||||||
|  |             logger.error(f"MikroTik failed: {e}") | ||||||
|             self.stats['failed'] += 1 |             self.stats['failed'] += 1 | ||||||
|             return False |             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: |     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