Browse Source

correcion

Pi3rrot 7 years ago
parent
commit
7f789a9078
1 changed files with 8 additions and 9 deletions
  1. 8 9
      myPKI.py

+ 8 - 9
myPKI.py

@@ -9,15 +9,15 @@ def usage():
 	print '\t-A --initall\t-i -g -d -s'
 	print '\t-i --init\tInitialise directorys of PKI'
 	print '\t-g --genca\tGenerate CA root'
-	print '\t-d --gender'
+	print '\t-d --gender\tGenerate DER cert for browser'
 	print '\t-s --gensign\tGenerate and sign certificate'
 	print '\t-h --help\tShows this help'
     
 def generate_sign():
 	tld = raw_input("=> TLD of your certificate :")
 	os.system("openssl genrsa -out ./certificats/"+tld+".key 4096")
-	os.system("openssl req -days 3000 -new -key ./certificats/"+tld+".key -out certificats/"+tld+".csr")
-	os.system("openssl ca -config config/ca.config -out "+tld+".crt -infiles certificats/"+tld+".csr")
+	os.system("openssl req -days 3000 -new -config config/ca.config -key ./certificats/"+tld+".key -out certificats/"+tld+".csr")
+	os.system("openssl ca -out "+tld+".crt -config config/ca.config -infiles certificats/"+tld+".csr ")
 	print "[*] Certificate Signed !"
 
 def generate_der():
@@ -27,14 +27,14 @@ def generate_der():
 def generate_ca():
 	if not os.path.isfile("./certificats/ca.key"):
 		os.system("openssl genrsa -out ./certificats/ca.key 4096")
-		os.system("openssl req -utf8 -new -x509 -days 3000 -key ./certificats/ca.key -out ./certificats/ca.crt")
+		os.system("openssl req -utf8 -new -x509 -days 3000 -config config/ca.config -key ./certificats/ca.key -out ./certificats/ca.crt")
 		print "[*] CA Certificate done !"
 	else:
 		print "[x] CA Certificate already exist..."
 		
 
 def init_dir():
-	if not os.path.exists("./db/ca.dbcerts"):
+	if not os.path.exists("./db/ca.db.certs"):
 		print "[*] Creating directories"
 		os.makedirs("./db/ca.db.certs")
 		os.makedirs("./config")
@@ -68,7 +68,8 @@ def init_dir():
 					"commonName              = supplied\n"+
 					"emailAddress            = it@imao-fr.com\n"+
 					"EOF\n")
-	print "[x] Directorys already exist"
+	else:
+		print "[x] Directorys already exist"
 	
 
 def main():
@@ -92,9 +93,7 @@ def main():
 				generate_ca()
 				generate_der()
 				generate_sign()
-
-			else:
-				error("option '"+o+"' doesn't exists")
+		sys.exit()
 
 	except getopt.GetoptError, err:
 		sys.stderr.write(str(err))