]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
python-common/cryptotools: Always encode, Err via stderr and signal the exit.
authorPaulo E. Castro <pecastro@wormholenet.com>
Tue, 22 Apr 2025 23:07:01 +0000 (00:07 +0100)
committerJohn Mulligan <jmulligan@redhat.com>
Mon, 7 Jul 2025 13:32:24 +0000 (09:32 -0400)
Signed-off-by: Paulo E. Castro <pecastro@wormholenet.com>
src/pybind/mgr/tests/test_tls.py
src/python-common/ceph/cryptotools/cryptotools.py
src/python-common/ceph/cryptotools/remote.py

index 39ba5ae0a03333635b01e2b4e2fcb9cbfb9a5a10..7cba929fe438f960114abe907185b1466d506903 100644 (file)
@@ -41,7 +41,6 @@ class TLSchecks(unittest.TestCase):
         new_key = crypto.PKey()
         new_key.generate_key(crypto.TYPE_RSA, 2048)
         new_key = crypto.dump_privatekey(crypto.FILETYPE_PEM, new_key).decode('utf-8')
-
         self.assertRaises(ServerConfigException, verify_tls, crt, new_key)
 
     def test_get_cert_issuer_info(self):
index dd9f5367b6a172ec82e1876247a7f751166ce3f0..e021cf82ad6b74c4dd148835bc16f596c6e34d48 100644 (file)
@@ -129,7 +129,8 @@ def get_cert_issuer_info(args: Namespace) -> None:
 
 
 def _fail_message(msg: str) -> None:
-    json.dump({'error': msg}, sys.stdout)
+    json.dump({'error': msg}, sys.stderr)
+    sys.exit(1)
 
 
 def verify_tls(args: Namespace) -> None:
index 1ad410814454add5470166e97e96c5fd0ef0e160..a83399828e1ff2a4e142388cb6c858a357bf6015 100644 (file)
@@ -55,16 +55,14 @@ class CryptoCaller:
     def _run(
         self,
         args: List[str],
-        input_data: Union[str, bytes, None] = None,
+        input_data: Union[str, None] = None,
         capture_output: bool = False,
         check: bool = False,
     ) -> subprocess.CompletedProcess:
         if input_data is None:
             _input = None
-        elif isinstance(input_data, str):
-            _input = input_data.encode('utf-8')
         else:
-            _input = input_data
+            _input = input_data.encode('utf-8')
         cmd = ['python3', '-m', _ctmodule] + list(args)
         logger.warning('CryptoCaller will run: %r', cmd)
         try: