proglottis / gpgme Goto Github PK
View Code? Open in Web Editor NEWGo wrapper for the GPGME library
Home Page: https://godoc.org/github.com/proglottis/gpgme
License: BSD 3-Clause "New" or "Revised" License
Go wrapper for the GPGME library
Home Page: https://godoc.org/github.com/proglottis/gpgme
License: BSD 3-Clause "New" or "Revised" License
✋ I'm trying to rewrite my personal project (https://github.com/sylvek/leeloo) in Go. I found your library 🙏 but sadely, when i did a stupid test of encryption, i have this error
github.com/proglottis/gpgme
# github.com/proglottis/gpgme
ld: library not found for -lassuan
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I'm on MacOS M1 and my own project already uses "gpgme".. so i assume it is installed fine.
Do you have any idea to fix this issue? 🤔
I have an error where the gpgme.FindKeys does not work as expected on windows. Any help on this would be appreciated. If there is more information that i can give to help, just let me know
package main
import (
"github.com/proglottis/gpgme"
"fmt"
)
func main() {
ctx, err := gpgme.New()
if err != nil {
panic(err)
}
defer ctx.Release()
fmt.Println(ctx.EngineInfo().Version())
}
when I run cmd go run main.go
An error is as follows
../GoCode/pkg/mod/github.com/proglottis/[email protected]/data.go:4:11: fatal error: gpgme.h: No such file or directory
// #include <gpgme.h>
^~~~~~~~~
compilation terminated.
This is more or less a FYI, I can’t think of a good fix at the level of this package:
Before GPGME 1.8.0, the default library was not thread-safe; instead of locking data structures, there was basically only an assertion (sanity check) that there is no concurrent user of the data. The users had to explicitly opt in to a thread-safe library, by using the
gpgme-config --thread=pthread --libs --cflags
instead of
gpgme-config --libs --cflags
to get the right flags; in practice (at least on recent Fedora-based systems), this amounts to using -lgpgme-pthread
instead of -lgpgme
.
Given how Go encourages multi-threading, this should basically be done all the time, for the pre-1.8.0 versions.
Unfortunately, more recent versions of GPGME don’t provide the gpgme-pthread
library, so we can’t just change the hard-coded library name, that would break everyone using recent versions.
All the discussions about possible fixes from #6 apply similarly here: a simple go build
can’t do this automatically. We could, possibly, add a build tag to let the user have a choice (requiring the final top-level executable to know about that build tag), but it’s even worse than #6 in that for #6, a user that doesn’t need the new symbols can just always use the old-symbol version without any environment-dependent logic. In this case, the decision is based not on how the gpgme
bindings are used, but on the surrounding environment, so every single top-level caller needs infrastructure to correctly choose the right binding.
Given that GPGME 1.8.0 is over 3 years old at this point, I’m not at all sure how much it is worth building any kind of infrastructure (build tags, detection scripts) for helping support this.
Thanks to Ulrich Obergfell [email protected] for diagnosing this.
When I try to build gpgme for my module running on Travis-CI for continuous integration, I get these (maybe cgo-related) errors:
go: downloading github.com/proglottis/gpgme v0.0.0-20170426024346-49ea2555b6fc
go: downloading golang.org/x/text v0.3.0
golang_org/x/crypto/cryptobyte/asn1
github.com/BurntSushi/toml
github.com/pkg/errors
github.com/proglottis/gpgme
golang_org/x/crypto/cryptobyte
golang_org/x/net/dns/dnsmessage
net
# github.com/proglottis/gpgme
../../../../pkg/mod/github.com/proglottis/[email protected]/gpgme.go:72:35: could not determine kind of name for C.GPGME_ENCRYPT_NO_COMPRESS
../../../../pkg/mod/github.com/proglottis/[email protected]/gpgme.go:556:38: could not determine kind of name for C.GPGME_EXPORT_MODE_PKCS12
../../../../pkg/mod/github.com/proglottis/[email protected]/gpgme.go:555:38: could not determine kind of name for C.GPGME_EXPORT_MODE_RAW
../../../../pkg/mod/github.com/proglottis/[email protected]/gpgme.go:554:38: could not determine kind of name for C.GPGME_EXPORT_MODE_SECRET
../../../../pkg/mod/github.com/proglottis/[email protected]/gpgme.go:86:40: could not determine kind of name for C.GPGME_KEYLIST_MODE_WITH_SECRET
../../../../pkg/mod/github.com/proglottis/[email protected]/gpgme.go:50:30: could not determine kind of name for C.GPGME_PROTOCOL_SPAWN
golang_org/x/crypto/internal/chacha20
Not sure how to fix these.
I am using golangci-lint on macos( arm64), the error is
could not import github.com/proglottis/gpgme (/Users/bytedance/goprojects/pkg/mod/github.com/proglottis/[email protected]/data.go:7:8: could not import C (cgo preprocessing failed)
INFO [runner] linters took 5.597801417s with stages: goanalysis_metalinter: 3.783535708s, unused: 1.814238875s
ERRO Running error: buildir: failed to load package gpgme: could not load export data: no export data for "github.com/proglottis/gpgme"
env
➜ ~ go version
go version go1.16.15 darwin/arm64
➜ ~ golangci-lint version
golangci-lint has version v1.37.1 built from (unknown, mod sum: "h1:Unt38FmBltdoILo6oQUMp6PuxwWbJ1YyNSStCrvA7+8=") on (unknown)
macos 13.2 M1/arm64
Hi there,
I'm trying to use this library on Windows using the msys2 mingw64.
First of all: if you want to try this yourself, you have to install the mingw gpgme library using pacman -S mingw-w64-x86_64-gpgme
and you have to do so in the mingw64 environment.
Now the problems:
For one, it complains when building the unsetenvGPGAgentInfo
function:
% go run main.go # github.com/proglottis/gpgme
could not determine kind of name for C.unsetenv
[1] 13260 exit 2 go run src/main/hostApp.go
when I just comment this line out (as I understand the comment, it is just used for testing?), I get this error:
# github.com/proglottis/gpgme
src\github.com\proglottis\gpgme\data.go:184: cannot use C.off_t(offset) (type C.off_t) as type C.gpgme_off_t in argument to func literal
changing the offending line to
n, err := C.gpgme_data_seek(d.dh, C.gpgme_off_t(offset), C.int(whence))
let's me compile everything.
I still haven't come around to really using the library yet, that will be my next step. I just thought I'd report what I've encountered so far.
Thanks for the wrapper, it's really appreciated.
I'm consuming a library at github.com/containers/image.. specifically this go module
github.com/containers/image/[email protected]
requires
github.com/proglottis/[email protected]
and it's causing my go tests to fail.
go test ./... -coverprofile cover.out
# github.com/proglottis/gpgme
../../go/pkg/mod/github.com/proglottis/[email protected]/data.go:4:11: fatal error: 'gpgme.h' file not found
It would be cool if you could include suggested solutions for getting this library installed in different OSes.
Maybe link to https://www.gnupg.org/download/index.html
For macos, one might use homebrew brew install gpgme
.
You may also have package managers such as apt
, dnf
, or yum
for your OS which contain may gpgme package.
The bindings provide symbols added in recent versions of gpgme, which makes it impossible to build them e.g. on Fedora 22 (gpgme 1.4.3) or RHEL 7 (gpgme 1.3.2).
I’m afraid I don’t know how to fix this cleanly; we probably can’t do a gpgme version check at compilation time using the native Go facilities, so this would involve adding a Makefile and conditional compilation tags… much uglier than the current clean package where a simple go build
suffices.
Holding the bindings back to and old gpgme version is not good enough either.
For now, I am maintaining https://github.com/mtrmac/gpgme/tree/gpgme143 and https://github.com/mtrmac/gpgme/tree/gpgme132 branches as the simplest way to build on these older systems, and this works well enough; still, I thought that it would be useful to file this here, either because somebody smarter can find a clean fix now, or so that it can be fixed sometime later after it becomes feasible.
hi,
first, thank you for this software, it looks quite useful and is used in a tool I am packaging for debian (dmarc-cat).
one problem with this dependency is that it doesn't have official releases. it makes it hard to find out when changes happen in the code base. it also makes tracking module dependencies with the new golang module system harder.
would you consider using official, tagged releases for your software?
again thank you for your time.
Hello, I have a module (https://github.com/keltia/archive) which encapsulate various "archive" formats including gpg encrypted (so I use it as a wrapper in my other modules). I used it in a tool which decrypt and extract CERT-EU files (https://github.com/keltia/erc-cimbl). It has stopped working a while ago and I have to decrypt manually now.
While looking at the issue in my archive
module, I find that gpgme
has a failing test with exactly the same message No Data
. Can you please investigate?
There are other failing tests but they are less of an issue (especially the last one as it is a local problem).
=== RUN TestNewData --- PASS: TestNewData (0.00s) === RUN TestNewDataBytes --- PASS: TestNewDataBytes (0.00s) === RUN TestDataNewDataFile --- PASS: TestDataNewDataFile (0.00s) === RUN TestDataNewDataReader --- PASS: TestDataNewDataReader (0.00s) === RUN TestDataNewDataWriter --- PASS: TestDataNewDataWriter (0.00s) === RUN TestEngineInfo --- PASS: TestEngineInfo (0.07s) === RUN TestContext_Armor --- PASS: TestContext_Armor (0.00s) === RUN TestContext_TextMode --- PASS: TestContext_TextMode (0.00s) === RUN TestContext_EngineInfo --- PASS: TestContext_EngineInfo (0.01s) === RUN TestContext_Encrypt --- FAIL: TestContext_Encrypt (0.01s) gpgme_test.go:184: Invalid value === RUN TestContext_Decrypt --- FAIL: TestContext_Decrypt (0.01s) gpgme_test.go:198: No data === RUN TestContext_DecryptVerify --- FAIL: TestContext_DecryptVerify (0.01s) gpgme_test.go:210: No data === RUN TestContext_Sign --- FAIL: TestContext_Sign (0.02s) gpgme_test.go:218: key "[email protected]" not found === RUN TestContext_Verify --- FAIL: TestContext_Verify (0.02s) gpgme_test.go:238: key "[email protected]" not found === RUN TestContext_Import --- FAIL: TestContext_Import (0.02s) gpgme_test.go:315: Unexpected import result field Considered, value 0, expected 1 gpgme_test.go:315: Unexpected import result field Imported, value 0, expected 1 gpgme_test.go:324: Unexpected number of import status values 0 === RUN TestContext_Export --- FAIL: TestContext_Export (0.01s) gpgme_test.go:344: Expected exported keys, got empty buffer === RUN TestContext_AssuanSend dyld: Library not loaded: /opt/local/lib/libreadline.6.dylib Referenced from: /opt/local/bin/gpg-connect-agent Reason: image not found --- SKIP: TestContext_AssuanSend (0.02s) gpgme_test.go:355: signal: abort trap FAIL FAIL github.com/proglottis/gpgme 0.196s
When building a tool that uses this package I get the following error:
pkg-config --cflags -- gpgme
Package gpgme was not found in the pkg-config search path.
Perhaps you should add the directory containing `gpgme.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gpgme' found
Looking at RHEL and CentOS 7 there doesn't appear to be a pkg config file for gpgme.
Is there a way to resolve the issue so this module can find the cflags?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.