@@ -269,7 +269,6 @@ def installSSLForDomain(virtualHostName, adminEmail='usman@cyberpersons.com'):
269269 return 1
270270
271271
272-
273272 @staticmethod
274273 def obtainSSLForADomain (virtualHostName ,adminEmail ,sslpath , aliasDomain = None ):
275274 try :
@@ -286,31 +285,41 @@ def obtainSSLForADomain(virtualHostName,adminEmail,sslpath, aliasDomain = None):
286285 subprocess .call (shlex .split (command ))
287286
288287 try :
289- logging .CyberCPLogFileWriter .writeToFile ("Trying to obtain SSL for: " + virtualHostName + " and: www." + virtualHostName )
288+ logging .CyberCPLogFileWriter .writeToFile ("Trying to obtain SSL for: " + virtualHostName + " and: www." + virtualHostName , 0 )
290289
291290 command = acmePath + " --issue -d " + virtualHostName + " -d www." + virtualHostName \
292291 + ' --cert-file ' + existingCertPath + '/cert.pem' + ' --key-file ' + existingCertPath + '/privkey.pem' \
293292 + ' --fullchain-file ' + existingCertPath + '/fullchain.pem' + ' -w ' + sslpath + ' --force'
294293
295- logging .CyberCPLogFileWriter .writeToFile (command )
294+ logging .CyberCPLogFileWriter .writeToFile (command , 0 )
296295
297296 output = subprocess .check_output (shlex .split (command )).decode ("utf-8" )
298- logging .CyberCPLogFileWriter .writeToFile ("Successfully obtained SSL for: " + virtualHostName + " and: www." + virtualHostName )
297+ logging .CyberCPLogFileWriter .writeToFile ("Successfully obtained SSL for: " + virtualHostName + " and: www." + virtualHostName , 0 )
298+
299+ logging .CyberCPLogFileWriter .SendEmail (adminEmail , adminEmail , output , 'SSL Notification for %s.' % (virtualHostName ))
299300
300301
301302 except subprocess .CalledProcessError :
302303 logging .CyberCPLogFileWriter .writeToFile (
303- "Failed to obtain SSL for: " + virtualHostName + " and: www." + virtualHostName )
304+ "Failed to obtain SSL for: " + virtualHostName + " and: www." + virtualHostName , 0 )
305+
306+ finalText = "Failed to obtain SSL for: " + virtualHostName + " and: www." + virtualHostName
304307
305308 try :
306- logging .CyberCPLogFileWriter .writeToFile ("Trying to obtain SSL for: " + virtualHostName )
309+ finalText = '%s\n Trying to obtain SSL for: %s' % (finalText , virtualHostName )
310+ logging .CyberCPLogFileWriter .writeToFile ("Trying to obtain SSL for: " + virtualHostName , 0 )
307311 command = acmePath + " --issue -d " + virtualHostName + ' --cert-file ' + existingCertPath \
308312 + '/cert.pem' + ' --key-file ' + existingCertPath + '/privkey.pem' \
309313 + ' --fullchain-file ' + existingCertPath + '/fullchain.pem' + ' -w ' + sslpath + ' --force'
310314 output = subprocess .check_output (shlex .split (command )).decode ("utf-8" )
311- logging .CyberCPLogFileWriter .writeToFile ("Successfully obtained SSL for: " + virtualHostName )
315+ logging .CyberCPLogFileWriter .writeToFile ("Successfully obtained SSL for: " + virtualHostName , 0 )
316+ finalText = '%s\n Successfully obtained SSL for: %s.' % (finalText , virtualHostName )
317+ logging .CyberCPLogFileWriter .SendEmail (adminEmail , adminEmail , finalText ,
318+ 'SSL Notification for %s.' % (virtualHostName ))
312319 except subprocess .CalledProcessError :
313- logging .CyberCPLogFileWriter .writeToFile ('Failed to obtain SSL, issuing self-signed SSL for: ' + virtualHostName )
320+ logging .CyberCPLogFileWriter .writeToFile ('Failed to obtain SSL, issuing self-signed SSL for: ' + virtualHostName , 0 )
321+ logging .CyberCPLogFileWriter .SendEmail (adminEmail , adminEmail , 'Failed to obtain SSL, issuing self-signed SSL for: ' + virtualHostName ,
322+ 'SSL Notification for %s.' % (virtualHostName ))
314323 return 0
315324 else :
316325
0 commit comments