Skip to content

Commit 9ccb98b

Browse files
saqibali-2kjlebon
authored andcommittedJul 15, 2021
Added a command to COSA for encrypting files using openssl
Added OpenSSL to dependencies
1 parent f26e869 commit 9ccb98b

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed
 

‎src/deps.txt

+3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ python3-flake8 python3-pytest python3-pytest-cov pylint
6262
# For cmd-virt-install
6363
python3-libvirt
6464

65+
# For pkcs7encrypt
66+
openssl
67+
6568
# Support for Koji uploads.
6669
krb5-libs krb5-workstation koji-utils python3-koji python3-koji-cli-plugins
6770

‎src/pkcs7encrypt

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/python3
2+
3+
# Used to encrypt files before upload (such as build.log)
4+
5+
import subprocess
6+
import argparse
7+
import os
8+
9+
10+
parser = argparse.ArgumentParser()
11+
parser.add_argument("cert", help="X.509 Certificate")
12+
parser.add_argument("input", help="Path to file to encrypt into PKCS7 structure")
13+
parser.add_argument("output", help="Path to encrypted PKCS7 structure")
14+
args = parser.parse_args()
15+
16+
files = [args.cert, args.input]
17+
for path in files:
18+
if not os.path.exists(path):
19+
raise FileNotFoundError(path)
20+
21+
subprocess.check_call(["openssl", "smime", "-encrypt", "-aes-256-cbc", "-in", args.input,
22+
"-out", args.output, "-outform", "PEM", args.cert])

0 commit comments

Comments
 (0)
Please sign in to comment.