update package - readme
This commit is contained in:
33
README.md
33
README.md
@@ -5,21 +5,20 @@
|
|||||||
[](https://coveralls.io/github/tecnickcom/go-xmlsec?branch=master)
|
[](https://coveralls.io/github/tecnickcom/go-xmlsec?branch=master)
|
||||||
[](https://goreportcard.com/report/git.deineagentur.com/DeineAgenturUG/go-xmlsec)
|
[](https://goreportcard.com/report/git.deineagentur.com/DeineAgenturUG/go-xmlsec)
|
||||||
|
|
||||||
|
|
||||||
A partial wrapper for [xmlsec](https://www.aleksey.com/xmlsec).
|
A partial wrapper for [xmlsec](https://www.aleksey.com/xmlsec).
|
||||||
|
|
||||||
As seems to be the case for many things in the XMLish world, the xmldsig and xmlenc standards are more complex that may be nessesary. This library is as general as I could reasonably make it with an eye towards supporting the parts of the standards that are needed to support a SAML implementation. If there are missing bits you feel you need, please raise an issue or submit a pull request.
|
As seems to be the case for many things in the XMLish world, the xmldsig and xmlenc standards are more complex that may be nessesary. This library is as general as I could reasonably make it with an eye towards supporting the parts of the standards that are needed to support a SAML implementation. If there are missing bits you feel you need, please raise an issue or submit a pull request.
|
||||||
|
|
||||||
# Examples
|
## Examples
|
||||||
|
|
||||||
## Signing
|
### Signing
|
||||||
|
|
||||||
key, _ := ioutil.ReadFile("saml.key")
|
key, _ := ioutil.ReadFile("saml.key")
|
||||||
doc, _ := ioutil.ReadAll(os.Stdin)
|
doc, _ := ioutil.ReadAll(os.Stdin)
|
||||||
signedDoc, err := Sign(key, doc, SignatureOptions{})
|
signedDoc, err := Sign(key, doc, SignatureOptions{})
|
||||||
os.Stdout.Write(signedDoc)
|
os.Stdout.Write(signedDoc)
|
||||||
|
|
||||||
## Verifying
|
### Verifying
|
||||||
|
|
||||||
key, _ := ioutil.ReadFile("saml.crt")
|
key, _ := ioutil.ReadFile("saml.crt")
|
||||||
doc, _ := ioutil.ReadAll(os.Stdin)
|
doc, _ := ioutil.ReadAll(os.Stdin)
|
||||||
@@ -28,21 +27,21 @@ As seems to be the case for many things in the XMLish world, the xmldsig and xml
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
## Decrypting
|
### Decrypting
|
||||||
|
|
||||||
key, _ := ioutil.ReadFile("saml.key")
|
key, _ := ioutil.ReadFile("saml.key")
|
||||||
doc, _ := ioutil.ReadAll(os.Stdin)
|
doc, _ := ioutil.ReadAll(os.Stdin)
|
||||||
plaintextDoc, err := Decrypt(key, doc)
|
plaintextDoc, err := Decrypt(key, doc)
|
||||||
os.Stdout.Write(plaintextDoc)
|
os.Stdout.Write(plaintextDoc)
|
||||||
|
|
||||||
## Encrypting
|
### Encrypting
|
||||||
|
|
||||||
key, _ := ioutil.ReadFile("saml.crt")
|
key, _ := ioutil.ReadFile("saml.crt")
|
||||||
doc, _ := ioutil.ReadAll(os.Stdin)
|
doc, _ := ioutil.ReadAll(os.Stdin)
|
||||||
encryptedDoc, err := Encrypt(key, doc, EncryptOptions{})
|
encryptedDoc, err := Encrypt(key, doc, EncryptOptions{})
|
||||||
os.Stdout.Write(encryptedDoc)
|
os.Stdout.Write(encryptedDoc)
|
||||||
|
|
||||||
# Install
|
## Install
|
||||||
|
|
||||||
This package uses cgo to wrap libxmlsec. As such, you'll need libxmlsec headers and a C compiler to make it work. On linux, this might look like:
|
This package uses cgo to wrap libxmlsec. As such, you'll need libxmlsec headers and a C compiler to make it work. On linux, this might look like:
|
||||||
|
|
||||||
@@ -54,33 +53,33 @@ On Mac with homebrew, this might look like:
|
|||||||
$ brew install libxmlsec1 libxml2 pkg-config
|
$ brew install libxmlsec1 libxml2 pkg-config
|
||||||
$ go get git.deineagentur.com/DeineAgenturUG/go-xmlsec
|
$ go get git.deineagentur.com/DeineAgenturUG/go-xmlsec
|
||||||
|
|
||||||
# Static Linking
|
## Static Linking
|
||||||
|
|
||||||
It may annoy you to grow a depenency on the shared libraries for libxmlsec, libxml2, etc. After some fighting, here is what I made work on Linux to get
|
It may annoy you to grow a depenency on the shared libraries for libxmlsec, libxml2, etc. After some fighting, here is what I made work on Linux to get
|
||||||
a static binary. See also `Dockerfile.build-static` which build the example
|
a static binary. See also `Dockerfile.build-static` which build the example
|
||||||
program using this method.
|
program using this method.
|
||||||
|
|
||||||
## Compile libxml
|
### Compile libxml
|
||||||
|
|
||||||
```
|
```shell
|
||||||
curl -sL ftp://xmlsoft.org/libxml2/libxml2-2.9.4.tar.gz | tar -xzf -
|
curl -sL ftp://xmlsoft.org/libxml2/libxml2-2.9.4.tar.gz | tar -xzf -
|
||||||
cd /libxml2-2.9.4
|
cd /libxml2-2.9.4
|
||||||
./configure --enable-static --disable-shared --without-gnu-ld --with-c14n --without-catalog --without-debug --without-docbook --without-fexceptions --without-ftp --without-history --without-html --without-http --without-iconv --without-icu --without-iso8859x --without-legacy --without-mem-debug --without-minimum --with-output --without-pattern --with-push --without-python --without-reader --without-readline --without-regexps --without-run-debug --with-sax1 --without-schemas --without-schematron --without-threads --without-thread-alloc --with-tree --without-valid --without-writer --without-xinclude --without-xpath --with-xptr --without-modules --without-zlib --without-lzma --without-coverage
|
./configure --enable-static --disable-shared --without-gnu-ld --with-c14n --without-catalog --without-debug --without-docbook --without-fexceptions --without-ftp --without-history --without-html --without-http --without-iconv --without-icu --without-iso8859x --without-legacy --without-mem-debug --without-minimum --with-output --without-pattern --with-push --without-python --without-reader --without-readline --without-regexps --without-run-debug --with-sax1 --without-schemas --without-schematron --without-threads --without-thread-alloc --with-tree --without-valid --without-writer --without-xinclude --without-xpath --with-xptr --without-modules --without-zlib --without-lzma --without-coverage
|
||||||
make install
|
make install
|
||||||
```
|
```
|
||||||
|
|
||||||
## Compile openssl
|
### Compile openssl
|
||||||
|
|
||||||
```
|
```shell
|
||||||
curl -sL ftp://ftp.openssl.org/source/openssl-1.0.2h.tar.gz | tar -xzf -
|
curl -sL ftp://ftp.openssl.org/source/openssl-1.0.2h.tar.gz | tar -xzf -
|
||||||
cd openssl-1.0.2h
|
cd openssl-1.0.2h
|
||||||
./config no-shared no-weak-ssl-ciphers no-ssl2 no-ssl3 no-comp no-idea no-dtls no-hw no-threads no-dso
|
./config no-shared no-weak-ssl-ciphers no-ssl2 no-ssl3 no-comp no-idea no-dtls no-hw no-threads no-dso
|
||||||
make install
|
make install
|
||||||
```
|
```
|
||||||
|
|
||||||
## Compile libxmlsec
|
### Compile libxmlsec
|
||||||
|
|
||||||
```
|
```shell
|
||||||
curl -sL http://www.aleksey.com/xmlsec/download/xmlsec1-1.2.22.tar.gz | tar -xzf -
|
curl -sL http://www.aleksey.com/xmlsec/download/xmlsec1-1.2.22.tar.gz | tar -xzf -
|
||||||
./configure --enable-static --disable-shared --disable-crypto-dl --disable-apps-crypto-dl --enable-static-linking --without-gnu-ld --with-default-crypto=openssl --with-openssl=/usr/local/ssl --with-libxml=/usr/local --without-nss --without-nspr --without-gcrypt --without-gnutls --without-libxslt
|
./configure --enable-static --disable-shared --disable-crypto-dl --disable-apps-crypto-dl --enable-static-linking --without-gnu-ld --with-default-crypto=openssl --with-openssl=/usr/local/ssl --with-libxml=/usr/local --without-nss --without-nspr --without-gcrypt --without-gnutls --without-libxslt
|
||||||
make -C src install
|
make -C src install
|
||||||
@@ -88,12 +87,10 @@ make -C include install
|
|||||||
make install-pkgconfigDATA
|
make install-pkgconfigDATA
|
||||||
```
|
```
|
||||||
|
|
||||||
## Build with static tag
|
### Build with static tag
|
||||||
|
|
||||||
```
|
```shell
|
||||||
go build -tags static -ldflags '-s -extldflags "-static"' -o /bin/xmldsig-static.bin ./examples/xmldsig.go
|
go build -tags static -ldflags '-s -extldflags "-static"' -o /bin/xmldsig-static.bin ./examples/xmldsig.go
|
||||||
```
|
```
|
||||||
|
|
||||||
Running `ldd` on the output should produce `not a dynamic executable`.
|
Running `ldd` on the output should produce `not a dynamic executable`.
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user