This is fork of amdonov/xmlsig Original canonization method is replaced with "ucarion/c14n" library.
The following example shows how to produce a simple signature.
import ( "crypto/tls" "encoding/xml" "os" "github.com/dpremus/xmlsig" ) func example() error { cert, err := tls.LoadX509KeyPair("cert.pem", "demo.key") if err != nil { return err } signer, err := xmlsig.NewSigner(cert) if err != nil { return err } doc := Test1{ Data: "Hello, World!", ID: "_1234", } sig, err := signer.CreateSignature(doc, doc.ID) if err != nil { return err } doc.Signature = sig encoder := xml.NewEncoder(os.Stdout) return encoder.Encode(doc) } type Test1 struct { XMLName xml.Name `xml:"urn:envelope Envelope"` ID string `xml:",attr"` Data string `xml:"urn:envelope Data"` Signature *xmlsig.Signature }