Skip to content

Commit 5ca2f41

Browse files
[sdn_tests]: Adding cert generation script and certs folder to pins_ondatra.
1 parent 3bb2951 commit 5ca2f41

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package(
2+
default_visibility = ["//visibility:public"],
3+
licenses = ["notice"],
4+
)
5+
6+
filegroup(
7+
name = "certs",
8+
srcs = glob(["*.pem"]),
9+
)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
rm ca_key.pem ca_crt.pem server_key.pem server_req.pem server_crt.pem server_ext.cnf client_key.pem client_req.pem client_crt.pem client_ext.cnf
2+
3+
echo subjectAltName = IP:"$1" > server_ext.cnf
4+
# 1. Generate CA's private key and self-signed certificate
5+
openssl req -x509 -newkey rsa:4096 -days 365 -nodes -keyout ca_key.pem -out ca_crt.pem -subj "/C=US"
6+
7+
# 2. Generate web server's private key and certificate signing request (CSR)
8+
openssl req -newkey rsa:4096 -nodes -keyout server_key.pem -out server_req.pem -subj "/CN='$1'"
9+
10+
# 3. Use CA's private key to sign web server's CSR and get back the signed certificate
11+
openssl x509 -req -in server_req.pem -days 100 -CA ca_crt.pem -CAkey ca_key.pem -CAcreateserial -out server_crt.pem -extfile server_ext.cnf
12+
13+
echo subjectAltName = IP:"$1" > client_ext.cnf
14+
# 4. Generate client's private key and certificate signing request (CSR)
15+
openssl req -newkey rsa:4096 -nodes -keyout client_key.pem -out client_req.pem -subj "/CN=*"
16+
17+
# 5. Use CA's private key to sign client's CSR and get back the signed certificate
18+
openssl x509 -req -in client_req.pem -days 100 -CA ca_crt.pem -CAkey ca_key.pem -CAcreateserial -out client_crt.pem -extfile client_ext.cnf

0 commit comments

Comments
 (0)