ueno / ruby-gpgme

a ruby interface to GnuPG Made Easy (GPGME).
GNU Lesser General Public License v2.1
232 stars 99 forks source link

Importing public key fails silently #121

Open acatighera opened 6 years ago

acatighera commented 6 years ago
-----BEGIN PGP PUBLIC KEY BLOCK-----

mQENBFugCQgBCADYbTZy4LLi5f/RY1dBu4JWxdi8VdzbpX39nmICwxFERZurbp36
pS3XjN8DByWXN2pCKj308Iq0Qu3sU4cPx37BBIu7oK2tD+zuu7vL0xmS0DDGAudD
cEpRuPmka+5j0KjAJ5Gw/59AWbowLzbxwSq0wP+wgXsX7pWNp9v5A4cDLG8UbLpk
oLbO9jXVhnUg2wJdCseN6vb8O14TTfT7ryXZy+bIx+yQSNtsNbKik067U2+ZGLdt
R+CCJAYgBUN/THilNazFPQW0VjG7Wh7oZDl23+aLdDpIEyKHntI+VCTPfd9I4fc0
lftXye0ypf2xPLe9y7+kTfkeI9jIzErWC/BXABEBAAG0OmRhaWx5cGF5IHRlc3Rl
ciAoa2V5IGZvciB1bml0IHRlc3RzKSA8dGVzdGVyQGRhaWx5cGF5LmNvbT6JAU4E
EwEIADgWIQQdm9e8+6W9LdycjqcXXmihN3vv5AUCW6AJCAIbAwULCQgHAgYVCgkI
CwIEFgIDAQIeAQIXgAAKCRAXXmihN3vv5CVPB/90SsuYy6aPclb4HsY4i8dQZHr1
p0J0JhQ6O3SOomJ69sj/lyJVM8aPuDKhhUNNeBfYg9vyw+Vp6wNTgJgoqNSOxukZ
QuSbZurWebYbJQHot8uoKI+jbW23psPVX53L1AqQlRPrFhXJ5G68MuxcHGsO8oNq
LUR9CWO8ki7gzGZCgGyLVVh9q41vtBqGLXbxrIDml0kDKHgUldRKxhc6WbSukT1I
d3RBbCpY6tfWBxbELoZdAGkylmjJj9J9fWf7IO84qbiw1OeQUklmbHTTEBTE9uOz
5KYEQaPhM4Z89CL1wQe49OlTMiMrWOPFPOcqMC7QJlBusN5dJIkO0VfxO4LWuQEN
BFugCQgBCACXK9hMOLWB22PrdfyoQ/8XOJI/ijPgAFvT6DJWYRq9GXlD6im5Um/Y
k/3wrH6L2Et9G0579rmWyLtIZcQY7AbHAISZLOZasNS8GPWhEFOXbmRODhW4+0UV
8zSkC+wC5s2uH9FxeG4HxhwWWeHfrOZv16mZsRktVMDM5i3QoNbUpGA65TROB2Xj
NjL+oU2zd7LrUu7/BwVSNHudMRRGqiKRD3L/6XWkygwu5snocoB4OafFenFJ+1G5
CgrEyF5/Ny8ebwY7aWtGi9F9QuXe3GfIbeW+cZ7q3xAslEHh+HW3slF8Z5pQ+sJM
+VMIKAqGotA2ZqU9qTGCXVXPQM4uY4MtABEBAAGJATYEGAEIACAWIQQdm9e8+6W9
LdycjqcXXmihN3vv5AUCW6AJCAIbDAAKCRAXXmihN3vv5LqNB/wM4huO0xcM8H7V
tfl0RBcHqkdGmVcW8V+T69FC21OkWUnBohHXB4jJgxczRbtMamNXjNK3M53wmP5i
eZ4L5SJWPWIGE4oALvNDduU1GFHy4MqflupWcBYo5wsizHEfwQnlVVPNO6Qu5Rkz
m68QO3Nd7UHj4ghdUaNFKQgZHRTPAymEpmkRyFmf0qEQvNK9xuECqkNcDpZcHHDL
NSxgkjkL6AXKT48yx6EJ865d5ndu2bUQMrvlpiKSMJZlefYpg/nK06w40qX9KxVW
MMHPv/1q0ZHX2Fa+dVMYrsRHFORKtkNW3iZlkUWKBTvljkJkTbKiMIifTX+Ba+fx
woRK5WeJ
=+0rk
-----END PGP PUBLIC KEY BLOCK-----

Here is the key that fails but I have tried many others (even ones not generated by me), none seem to work. Here is the import result:

#<GPGME::ImportResult:0x000000000e0e4fd0 @considered=0, @no_user_id=0, @imported=0, @imported_rsa=0, @unchanged=0, @new_user_ids=0, @new_sub_keys=0, @new_signatures=0, @new_revocations=0, @secret_read=0, @secret_imported=0, @secret_unchanged=0, @not_imported=0, @imports=[]>

The strange thing is that on my Macbook everything works fine. However, on an ubuntu server it seems to crap out. The only thing I can think to attribute it to is the version of GPGME. On my macbook it is 2.2.4 and on the ubuntu server it is 1.4.20. Is there an easy way to require 2.x? Would that even fix the issue? Thank you for the assistance, it is much appreciated!

TTD93 commented 5 years ago

+1

kenhee commented 4 years ago

+1

Cakey123445 commented 1 year ago

+1 Bump. Same issue here.

Cakey123445 commented 1 year ago

For whomever lands here again at some point in the future then the issue for us was that the Rails user under linux (nobody) is a nologin account and as such there is no env variable for GPG to use for the home directory, the fix was to add this line to the initialisation code when decrypting.

GPGME::Engine.home_dir="/home/nobody/.gnupg" unless Rails.env=='development'