
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
proxy-git.cwkhome.fun/moov-io/signedxml
The signedxml package transforms and validates signed xml documents. The main use case is to support Single Sign On protocols like SAML and WS-Federation.
Other packages that provide similar functionality rely on C libraries, which makes them difficult to run across platforms without significant configuration. signedxml
is written in pure go, and can be easily used on any platform. This package was originally created by Matt Smith and is in use at Moov Financial.
go get github.com/moov-io/signedxml
Hashes
Signatures
Canonicalization Methods/Transforms
If your signed xml contains the signature and certificate, then you can just pass in the xml and call ValidateReferences()
.
validator, err := signedxml.NewValidator(`<YourXMLString></YourXMLString>`)
xml, err = validator.ValidateReferences()
ValidateReferences()
verifies the DigestValue and SignatureValue in the xml document, and returns the signed payload(s). If the error value is nil
, then the signed xml is valid.
The x509.Certificate that was successfully used to validate the xml will be available by calling:
validator.SigningCert()
You can then verify that you trust the certificate. You can optionally supply your trusted certificates ahead of time by assigning them to the Certificates
property of the Validator
object, which is an x509.Certificate array.
If you need to specify an external Signature, you can use the SetSignature()
function to assign it:
validator.SetSignature(<`Signature></Signature>`)
It is expected that your XML contains the Signature element with all the parameters set (except DigestValue and SignatureValue).
signer, err := signedxml.NewSigner(`<YourXMLString></YourXMLString`)
signedXML, err := signer.Sign(`*rsa.PrivateKey object`)
Sign()
will generate the DigestValue and SignatureValue, populate it in the XML, and return the signed XML string.
Additional Transform algorithms can be included by adding to the CanonicalizationAlgorithms map. This interface will need to be implemented:
type CanonicalizationAlgorithm interface {
Process(inputXML string, transformXML string) (outputXML string, err error)
}
Simple Example:
type NoChangeCanonicalization struct{}
func (n NoChangeCanonicalization) Process(inputXML string,
transformXML string) (outputXML string, err error) {
return inputXML, nil
}
signedxml.CanonicalizationAlgorithms["http://myTranform"] = NoChangeCanonicalization{}
See envelopedsignature.go
and exclusivecanonicalization.go
for examples of actual implementations.
It is possible to set a custom reference ID attribute for both the signer and the validator. The default value is "ID"
Signer example:
signer.SetReferenceIDAttribute("customId")
Validator example:
validator.SetReferenceIDAttribute("customId")
channel | info |
---|---|
Twitter @moov | You can follow Moov.io's Twitter feed to get updates on our project(s). You can also tweet us questions or just share blogs or stories. |
GitHub Issue | If you are able to reproduce a problem please open a GitHub Issue under the specific project that caused the error. |
moov-io slack | Join our slack channel to have an interactive discussion about the development of the project. |
Contributions are welcome. Just fork the repo and send a pull request.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.