From 9a878d8e762acd99c7fb0bc2a324e1359efbdfb7 Mon Sep 17 00:00:00 2001 From: Tim Ebringer Date: Sun, 15 Jan 2017 15:59:04 -0500 Subject: [PATCH] Fix breakages on Fedora 25 On Fedora 25, tests fail with error func=xmlSecCryptoAppInit:file=app.c:line=1423: obj=unknown:subj=cryptoAppInit:error=9: feature is not implemented: panic: xmlsec crypto initialization failed. This appears to be because the pkg-config files set the wrong CFLAGS defines for cgo, which results in runtime breakage beacuse OpenSSL isn't properly loaded. In order to fix how Fedora sets up these packages we want defines XMLSEC_CRYPTO_OPENSSL set, XMLSEC_CRYPTO_DYNAMIC_LOADING unset and we want to force linking with xmlsec1-openssl. This change puts these in cgo directives. We also fix a test which now has some off-by-one line number changes in the error message. --- decrypt_test.go | 2 +- xmlsec.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/decrypt_test.go b/decrypt_test.go index d1533ee..8a40128 100644 --- a/decrypt_test.go +++ b/decrypt_test.go @@ -177,7 +177,7 @@ func (testSuite *DecryptTest) TestInvalid(c *C) { `) _, err = Decrypt(testSuite.Key, docStr) - c.Assert(err, ErrorMatches, "func=xmlSecBase64CtxDecodeByte:file=base64.c:line=441:obj=:subj=:error=12:inByte=0x3f; func=xmlSecBase64CtxDecode:file=base64.c:line=612:obj=:subj=xmlSecBase64CtxDecodeByte:error=1:status=4; func=xmlSecBase64CtxUpdate:file=base64.c:line=268:obj=:subj=xmlSecBase64CtxDecode:error=1: ; func=xmlSecBase64Decode:file=base64.c:line=754:obj=:subj=xmlSecBase64CtxUpdate:error=1: ; func=xmlSecOpenSSLX509CertBase64DerRead:file=x509.c:line=1867:obj=:subj=xmlSecBase64Decode:error=1: ; func=xmlSecOpenSSLX509CertificateNodeRead:file=x509.c:line=981:obj=x509:subj=xmlSecOpenSSLX509CertBase64DerRead:error=1: ; func=xmlSecOpenSSLX509DataNodeRead:file=x509.c:line=942:obj=x509:subj=X509Certificate:error=1:read node failed; func=xmlSecOpenSSLKeyDataX509XmlRead:file=x509.c:line=674:obj=x509:subj=xmlSecOpenSSLX509DataNodeRead:error=1: ; func=xmlSecKeyInfoNodeRead:file=keyinfo.c:line=114:obj=x509:subj=xmlSecKeyDataXmlRead:error=1:node=X509Data; func=xmlSecKeysMngrGetKey:file=keys.c:line=1349:obj=:subj=xmlSecKeyInfoNodeRead:error=1:node=KeyInfo; func=xmlSecEncCtxEncDataNodeRead:file=xmlenc.c:line=957:obj=:subj=:error=45: ; func=xmlSecEncCtxDecryptToBuffer:file=xmlenc.c:line=715:obj=:subj=xmlSecEncCtxEncDataNodeRead:error=1: ; func=xmlSecKeysMngrGetKey:file=keys.c:line=1370:obj=:subj=xmlSecKeysMngrFindKey:error=1: ; func=xmlSecEncCtxEncDataNodeRead:file=xmlenc.c:line=957:obj=:subj=:error=45: ; func=xmlSecEncCtxDecryptToBuffer:file=xmlenc.c:line=715:obj=:subj=xmlSecEncCtxEncDataNodeRead:error=1: ; func=xmlSecEncCtxDecrypt:file=xmlenc.c:line=623:obj=:subj=xmlSecEncCtxDecryptToBuffer:error=1: ") + c.Assert(err, ErrorMatches, "func=xmlSecBase64CtxDecodeByte:file=base64.c:line=441:obj=:subj=:error=12:inByte=0x3f; func=xmlSecBase64CtxDecode:file=base64.c:line=612:obj=:subj=xmlSecBase64CtxDecodeByte:error=1:status=4; func=xmlSecBase64CtxUpdate:file=base64.c:line=268:obj=:subj=xmlSecBase64CtxDecode:error=1: ; func=xmlSecBase64Decode:file=base64.c:line=754:obj=:subj=xmlSecBase64CtxUpdate:error=1: ; func=xmlSecOpenSSLX509CertBase64DerRead:file=x509.c:line=\\d+:obj=:subj=xmlSecBase64Decode:error=1: ; func=xmlSecOpenSSLX509CertificateNodeRead:file=x509.c:line=\\d+:obj=x509:subj=xmlSecOpenSSLX509CertBase64DerRead:error=1: ; func=xmlSecOpenSSLX509DataNodeRead:file=x509.c:line=\\d+:obj=x509:subj=X509Certificate:error=1:read node failed; func=xmlSecOpenSSLKeyDataX509XmlRead:file=x509.c:line=\\d+:obj=x509:subj=xmlSecOpenSSLX509DataNodeRead:error=1: ; func=xmlSecKeyInfoNodeRead:file=keyinfo.c:line=114:obj=x509:subj=xmlSecKeyDataXmlRead:error=1:node=X509Data; func=xmlSecKeysMngrGetKey:file=keys.c:line=1349:obj=:subj=xmlSecKeyInfoNodeRead:error=1:node=KeyInfo; func=xmlSecEncCtxEncDataNodeRead:file=xmlenc.c:line=957:obj=:subj=:error=45: ; func=xmlSecEncCtxDecryptToBuffer:file=xmlenc.c:line=715:obj=:subj=xmlSecEncCtxEncDataNodeRead:error=1: ; func=xmlSecKeysMngrGetKey:file=keys.c:line=1370:obj=:subj=xmlSecKeysMngrFindKey:error=1: ; func=xmlSecEncCtxEncDataNodeRead:file=xmlenc.c:line=957:obj=:subj=:error=45: ; func=xmlSecEncCtxDecryptToBuffer:file=xmlenc.c:line=715:obj=:subj=xmlSecEncCtxEncDataNodeRead:error=1: ; func=xmlSecEncCtxDecrypt:file=xmlenc.c:line=623:obj=:subj=xmlSecEncCtxDecryptToBuffer:error=1: ") docStr = []byte(` diff --git a/xmlsec.go b/xmlsec.go index da695c9..9472792 100644 --- a/xmlsec.go +++ b/xmlsec.go @@ -6,6 +6,8 @@ import "unsafe" // brew install libxmlsec1 libxml2 // brew link libxml2 --force +// #cgo CFLAGS: -DXMLSEC_CRYPTO_OPENSSL -UXMLSEC_CRYPTO_DYNAMIC_LOADING +// #cgo LDFLAGS: -lxmlsec1-openssl // #include // #include // #include