7

Im using GPG to encrypt a file in ASP.NET, C#. My code executes the command using ProcessStartInfo, and gpg.exe executes, but I have an issue. GPG asks me to authorize always-trust with "y" as the option. I tried using "YES" as well (As suggested in GPG help, to assume "yes" for all questions), but that didn't work either.

The string that runs GPG is:

"gpg --armor --output fileOutput.gpg --recipient secure@site.com --encrypt fileInput.xml --always-trust --yes"

The question that's prompted is:

It is NOT certain that the key belongs to the person named in the user ID. If you really know what you are doing, you may answer the next question with yes

Use this key anyway?

How can I ignore the question altogether, or force the answer to be true ("YES") without being prompted to confirm?

Thanks.

James Johnson
  • 45,496
  • 8
  • 73
  • 110
iLevi
  • 936
  • 4
  • 10
  • 26

4 Answers4

4

add --always-trust as a command line argument to gpg to take the prompt away.

Spudley
  • 166,037
  • 39
  • 233
  • 307
daemonza
  • 527
  • 5
  • 16
0

You can use SendKeys.SendWait

http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.sendwait.aspx

manojlds
  • 290,304
  • 63
  • 469
  • 417
0

You need only to specify the trust model "always" by using the "--trust-model" option.

For Example:

gpg --trust-model always --armor --output fileOutput.gpg --recipient secure@site.com --encrypt fileInput.xml
kylehuff
  • 5,177
  • 2
  • 34
  • 35
-1

Pipe a "y" to your command:

echo "y" | <your command>
Arun
  • 2,493
  • 15
  • 12