Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not working for me #24

Open
elangelo opened this issue Feb 25, 2017 · 5 comments
Open

not working for me #24

elangelo opened this issue Feb 25, 2017 · 5 comments

Comments

@elangelo
Copy link

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'

@freewil
Copy link
Collaborator

freewil commented Apr 3, 2017

I welcome bug reports, but this sounds like it may be a question better directed to stack overflow

@elangelo
Copy link
Author

elangelo commented Apr 3, 2017

I'd call it a bug in the documentation then.

@Champii
Copy link

Champii commented Apr 27, 2017

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

@florianbehrens
Copy link

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.

@victorjoel44
Copy link

victorjoel44 commented Apr 22, 2018

Did you fix it? do you have the source code? @elangelo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants