I'm trying to call certutil from inside python. However I need to use quotation marks and have been unable to do so. My code is as follows:
import subprocess
output= subprocess.Popen(("certutil.exe", "-view", '-restrict "NotAfter <= now+30:00, NotAfter >= now+00:00"' ), stdout=subprocess.PIPE).stdout
for line in output:
print(line)
output.close()
I thought the single quotes would allow me to use double quotes inside the string.
Also I have tried using double quotes with the escape character (\"
), however I keep getting the same error:
Unknown arg: -restrict \\NotAfter\r\n'
For some reason it seems to be translating "
into \\
.
Can anyone give insight as to why and how to fix it?