@@ 448-489 (lines=42) @@ | ||
445 | preferences=preferences, |
|
446 | ) |
|
447 | ||
448 | def create_tls_certificate( |
|
449 | self, |
|
450 | name: str, |
|
451 | certificate: str, |
|
452 | *, |
|
453 | comment: Optional[str] = None, |
|
454 | trust: Optional[bool] = None |
|
455 | ) -> Any: |
|
456 | """Create a new TLS certificate |
|
457 | ||
458 | Arguments: |
|
459 | name: Name of the TLS certificate, defaulting to the MD5 |
|
460 | fingerprint. |
|
461 | certificate: The Base64 encoded certificate data (x.509 DER or PEM). |
|
462 | comment: Comment for the TLS certificate. |
|
463 | trust: Whether the certificate is trusted. |
|
464 | ||
465 | Returns: |
|
466 | The response. See :py:meth:`send_command` for details. |
|
467 | """ |
|
468 | if not name: |
|
469 | raise RequiredArgument( |
|
470 | function=self.create_tls_certificate.__name__, argument='name' |
|
471 | ) |
|
472 | if not certificate: |
|
473 | raise RequiredArgument( |
|
474 | function=self.create_tls_certificate.__name__, |
|
475 | argument='certificate', |
|
476 | ) |
|
477 | ||
478 | cmd = XmlCommand("create_tls_certificate") |
|
479 | ||
480 | if comment: |
|
481 | cmd.add_element("comment", comment) |
|
482 | ||
483 | cmd.add_element("name", name) |
|
484 | cmd.add_element("certificate", certificate) |
|
485 | ||
486 | if trust: |
|
487 | cmd.add_element("trust", _to_bool(trust)) |
|
488 | ||
489 | return self._send_xml_command(cmd) |
|
490 | ||
491 | def get_tls_certificates( |
|
492 | self, |
|
@@ 827-864 (lines=38) @@ | ||
824 | auto_add_new_nvts=auto_add_new_nvts, |
|
825 | ) |
|
826 | ||
827 | def modify_tls_certificate( |
|
828 | self, |
|
829 | tls_certificate_id: str, |
|
830 | *, |
|
831 | name: Optional[str] = None, |
|
832 | comment: Optional[str] = None, |
|
833 | trust: Optional[bool] = None |
|
834 | ) -> Any: |
|
835 | """Modifies an existing TLS certificate. |
|
836 | ||
837 | Arguments: |
|
838 | tls_certificate_id: UUID of the TLS certificate to be modified. |
|
839 | name: Name of the TLS certificate, defaulting to the MD5 fingerprint |
|
840 | comment: Comment for the TLS certificate. |
|
841 | trust: Whether the certificate is trusted. |
|
842 | ||
843 | Returns: |
|
844 | The response. See :py:meth:`send_command` for details. |
|
845 | """ |
|
846 | if not tls_certificate_id: |
|
847 | raise RequiredArgument( |
|
848 | function=self.modify_tls_certificate.__name__, |
|
849 | argument='tls_certificate_id', |
|
850 | ) |
|
851 | ||
852 | cmd = XmlCommand("modify_tls_certificate") |
|
853 | cmd.set_attribute("tls_certificate_id", str(tls_certificate_id)) |
|
854 | ||
855 | if comment: |
|
856 | cmd.add_element("comment", comment) |
|
857 | ||
858 | if name: |
|
859 | cmd.add_element("name", name) |
|
860 | ||
861 | if trust: |
|
862 | cmd.add_element("trust", _to_bool(trust)) |
|
863 | ||
864 | return self._send_xml_command(cmd) |
|
865 | ||
866 | def clone_tls_certificate(self, tls_certificate_id: str) -> Any: |
|
867 | """Modifies an existing TLS certificate. |