Skip to content

Generate SSL certificates for local testing #1756

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions test/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,35 @@ def get_open_port():
sock.close()
return port

def gen_ssl_resources(directory):
os.system("""
cd {0}
echo Generating SSL resources in {0}

# Step 1
keytool -keystore kafka.server.keystore.jks -alias localhost -validity 1 \
-genkey -storepass foobar -keypass foobar \
-dname "CN=localhost, OU=kafka-python, O=kafka-python, L=SF, ST=CA, C=US" \
-ext SAN=dns:localhost

# Step 2
openssl genrsa -out ca-key 2048
openssl req -new -x509 -key ca-key -out ca-cert -days 1 \
-subj "/C=US/ST=CA/O=MyOrg, Inc./CN=mydomain.com"
keytool -keystore kafka.server.truststore.jks -alias CARoot -import \
-file ca-cert -storepass foobar -noprompt

# Step 3
keytool -keystore kafka.server.keystore.jks -alias localhost -certreq \
-file cert-file -storepass foobar
openssl x509 -req -CA ca-cert -CAkey ca-key -in cert-file -out cert-signed \
-days 1 -CAcreateserial -passin pass:foobar
keytool -keystore kafka.server.keystore.jks -alias CARoot -import \
-file ca-cert -storepass foobar -noprompt
keytool -keystore kafka.server.keystore.jks -alias localhost -import \
-file cert-signed -storepass foobar -noprompt
""".format(directory))

class Fixture(object):
kafka_version = os.environ.get('KAFKA_VERSION', '0.11.0.2')
scala_version = os.environ.get("SCALA_VERSION", '2.8.0')
Expand Down