not working for me
I'm probably doing something very stupid but i guess i'll need some help.
var gpg = require('gpg');
var fs = require('fs');
var keyFile = '/home/samuel/file-enc-pubkey.txt'
gpg.importKeyFromFile(keyFile, function (err, result, fingerprint) {
if (err) {
console.log(err);
}
var readStream = fs.createReadStream('file.txt');
var writeStream = fs.createWriteStream('file.txt.gpg');
var args = [
'--encrypt',
'--recipient', fingerprint,
'--armor',
'--trust-model', 'always'
];
gpg.encryptToStream({source: readStream, dest: writeStream, args: args}, function(error, writeStream){
if (error){
console.log(error);
}
});
});
This code give me no errors at all but i get an empty file at the end... if i use the simple encrypt method i can see that my callback does contain 'stuff'
I welcome bug reports, but this sounds like it may be a question better directed to stack overflow
I'd call it a bug in the documentation then.
Hi, it is a known bug relative to the node-gpg streaming API. It swallow every critical error as gpg binary is unclear on how to trigger errors correctly.
You may have to check if your key and parameters are well set.
Try to build a shell command line with them.
A fix is in the pipe for this bug, but its pretty hard to manage error flows from gpg so dont expect it to come early.
Cheers
The problem is possibly that the callback you provide in gpg.encryptToStream() is only called once here. This is done as soon as the subprocess is spawned. If an error occurs later, the shot is already fired.
It worked for me with L104 commented out. The callback at that time makes IMHO no sense anyway.
Did you fix it? do you have the source code? @elangelo