#NEWLINE# @ lazy #NEWLINE# def generate_ssl_keys( depl_id , ssl_config ) : #NEWLINE# #INDENT# '\n    Done with the help of\n    https://www.digitalocean.com/community/articles/how-to-create-a-ssl-certificate-on-nginx-for-ubuntu-12-04\n    and some other good influences.\n    ' #NEWLINE# ssl_file_path = ( SSL_FILE_PATH % depl_id ) #NEWLINE# pass_out = ' -passout pass:depl' #NEWLINE# pass_in = ' -passin pass:depl' #NEWLINE# sudo ( ( 'mkdir %s || true' % SSL_PATH ) ) #NEWLINE# if ssl_config [ 'key' ] : #NEWLINE# #INDENT# put ( ssl_config [ 'key' ] , ( ssl_file_path + '.key' ) , use_sudo = True ) #NEWLINE# put ( ssl_config [ 'certificate' ] , ( ssl_file_path + '.crt' ) , use_sudo = True ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not files . exists ( ( ssl_file_path + '.key' ) ) ) : #NEWLINE# #INDENT# sudo ( 'openssl genrsa -des3 {1} -out {0}.key.orig 1024' . format ( ssl_file_path , pass_out ) ) #NEWLINE# sudo ( 'echo -e "\n\n\n\n\n\n\n\n" | openssl req -new -key {0}.key.orig -out {0}.csr {1}' . format ( ssl_file_path , pass_in ) ) #NEWLINE# sudo ( 'openssl rsa -in {0}.key.orig -out {0}.key {1}' . format ( ssl_file_path , pass_in ) ) #NEWLINE# #UNINDENT# if ( not files . exists ( ( ssl_file_path + '.crt' ) ) ) : #NEWLINE# #INDENT# sudo ( 'openssl x509 -req -days 9999 -in {0}.csr -signkey {0}.key -out {0}.crt' . format ( ssl_file_path ) )