Skip to content
/ xmlsig Public
forked from amdonov/xmlsig

Simple Go library for add digital signatures to XML documents

License

Notifications You must be signed in to change notification settings

dpremus/xmlsig

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

XML Signature library for Golang

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
}

About

Simple Go library for add digital signatures to XML documents

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%