spacemonkeygo / openssl

OpenSSL bindings for Go
http://godoc.org/github.com/spacemonkeygo/openssl
Apache License 2.0
474 stars 237 forks source link

Could not determine kind of name for C.SSLv3_method #49

Closed jphastings closed 7 years ago

jphastings commented 8 years ago

I'm building my application within a golang docker container (which uses debian Jessie), but I'm getting the error could not determine kind of name for C.SSLv3_method. I installed libopenssl-1.0.2e.

I'm quite new to go, any ideas what I'm doing wrong?

You can reproduce the problem with:

docker run -i -t golang /bin/bash
echo "deb http://httpredir.debian.org/debian stretch main" >> /etc/apt/sources.list
apt-get update
apt-get install -y libssl-dev pkg-config
go get github.com/spacemonkeygo/openssl
jtolio commented 8 years ago

On phone, so I'll look into this when I have a computer, but any particular reason you're adding the stretch sources to your container?

jphastings commented 8 years ago

It seemed like a simple way to get the libczmq-dev library I'm also using - it seems to be the source of the problem! I'll compile from source.

Solved from a phone - thanks @jtolds!

jtolio commented 8 years ago

\o/ glad to have helped!

jtolio commented 8 years ago

You can always add the stretch sources, but then add some pinning preferences to prefer packages from jessie unless otherwise specified.

If you made /etc/apt/preferences.d/stretch that contained

Package: *
Pin: release n=stretch
Pin-Priority: -10

then you should be safe where nothing from stretch will get installed unless you manually do something like apt-get install -t stretch libczmq-dev

maybe that might save some time for you?

petres commented 8 years ago

I got the same error message:

~$go get github.com/spacemonkeygo/openssl

github.com/spacemonkeygo/openssl

could not determine kind of name for C.SSLv3_method`

I am on Arch linux, go version is 1.6, the openssl version installed is 1.0.2.g-3. Any idea? Thanks!

petres commented 8 years ago

@jtolds Should I reopen the issue?

jtolio commented 8 years ago

yeah go ahead and reopen. it's hard cause having these bindings work against all the different versions of openssl is like trying to shoot multiple moving targets with one bullet. i'll try and figure out how to get this to work so SSLv3 doesn't work if the openssl you're linking against doesn't support it

jtolio commented 8 years ago

oh yeah i can reopen too

ncopa commented 7 years ago

I got the same error when trying to build mongodb-tools. This is the patch I added to fix it:

diff --git a/vendor/src/github.com/spacemonkeygo/openssl/ctx.go b/vendor/src/github.com/spacemonkeygo/openssl/ctx.go
index 22d6dd1..894fecd 100644
--- a/vendor/src/github.com/spacemonkeygo/openssl/ctx.go
+++ b/vendor/src/github.com/spacemonkeygo/openssl/ctx.go
@@ -140,8 +140,8 @@ const (
 func NewCtxWithVersion(version SSLVersion) (*Ctx, error) {
        var method *C.SSL_METHOD
        switch version {
-       case SSLv3:
-               method = C.SSLv3_method()
+//     case SSLv3:
+//             method = C.SSLv3_method()
        case TLSv1:
                method = C.TLSv1_method()
        case TLSv1_1:
diff --git a/vendor/src/github.com/spacemonkeygo/openssl/hostname.c b/vendor/src/github.com/spacemonkeygo/openssl/hostname.c
index 7ebea17..41c5951 100644
--- a/vendor/src/github.com/spacemonkeygo/openssl/hostname.c
+++ b/vendor/src/github.com/spacemonkeygo/openssl/hostname.c
@@ -346,7 +346,7 @@ static int do_x509_check(X509 *x, const unsigned char *chk, size_t chklen,
        return 0;
        }

-#if OPENSSL_VERSION_NUMBER < 0x1000200fL
+#if OPENSSL_VERSION_NUMBER < 0x1000200fL || defined(LIBRESSL_VERSION_NUMBER)

 int X509_check_host(X509 *x, const unsigned char *chk, size_t chklen,
                                        unsigned int flags)

First hunk is probably a bit controversial but second hunk can be upstreamed as is.

Thanks!

zeebo commented 7 years ago

Closing this in favor of pull request #71 to track it.