@@ -201,24 +201,19 @@ def _parse_config(self, ctxt):
201201 cms_cmd = 'openssl cms -inform DER -decrypt -recip {0} -inkey {1}' .format (cert ,pkey )
202202 smime_cmd = 'openssl smime -inform DER -decrypt -recip {0} -inkey {1}' .format (cert ,pkey )
203203
204- protected_settings_str = None
204+ protected_settings_str = ''
205205 for decrypt_cmd in [cms_cmd , smime_cmd ]:
206206 try :
207- session = subprocess .Popen ([decrypt_cmd ], shell = True ,
208- stdin = subprocess .PIPE ,
209- stderr = subprocess .STDOUT ,
210- stdout = subprocess .PIPE )
211- output = session .communicate (unencodedSettings )
212- # success only if return code is 0 and we have output
213- if session .returncode == 0 and output [0 ]:
214- protected_settings_str = output [0 ]
207+ output = waagent .RunSendStdin (decrypt_cmd , unencodedSettings )
208+ if output [0 ] == 0 and output [1 ]:
209+ protected_settings_str = output [1 ]
215210 if decrypt_cmd == cms_cmd :
216211 self .log ('Decrypted protectedSettings using openssl cms.' )
217212 else :
218213 self .log ('Decrypted protectedSettings using openssl smime fallback.' )
219214 break
220215 else :
221- self .log ('Attempt to decrypt protectedSettings with "{0}" failed (rc={1}).' .format (decrypt_cmd , session . returncode ))
216+ self .log ('Attempt to decrypt protectedSettings with "{0}" failed (rc={1}).' .format (decrypt_cmd , output [ 0 ] ))
222217 except OSError :
223218 pass
224219
0 commit comments