add URI attribute to <Reference>
This commit is contained in:
53
signature.go
53
signature.go
@@ -10,6 +10,18 @@ import (
|
||||
type Method struct {
|
||||
Algorithm string `xml:",attr"`
|
||||
}
|
||||
type Reference struct {
|
||||
URI string `xml:"URI,attr"`
|
||||
ReferenceTransforms []Method `xml:"Transforms>Transform"`
|
||||
DigestMethod Method `xml:"DigestMethod"`
|
||||
DigestValue string `xml:"DigestValue"`
|
||||
}
|
||||
|
||||
type SignedInfo struct {
|
||||
CanonicalizationMethod Method `xml:"CanonicalizationMethod"`
|
||||
SignatureMethod Method `xml:"SignatureMethod"`
|
||||
Reference Reference `xml:"Reference"`
|
||||
}
|
||||
|
||||
// Signature is a model for the Signature object specified by XMLDSIG. This is
|
||||
// convenience object when constructing XML that you'd like to sign. For example:
|
||||
@@ -25,16 +37,11 @@ type Method struct {
|
||||
// buf, _ = Sign(key, buf)
|
||||
//
|
||||
type Signature struct {
|
||||
XMLName xml.Name `xml:"http://www.w3.org/2000/09/xmldsig# Signature"`
|
||||
|
||||
CanonicalizationMethod Method `xml:"SignedInfo>CanonicalizationMethod"`
|
||||
SignatureMethod Method `xml:"SignedInfo>SignatureMethod"`
|
||||
ReferenceTransforms []Method `xml:"SignedInfo>Reference>Transforms>Transform"`
|
||||
DigestMethod Method `xml:"SignedInfo>Reference>DigestMethod"`
|
||||
DigestValue string `xml:"SignedInfo>Reference>DigestValue"`
|
||||
SignatureValue string `xml:"SignatureValue"`
|
||||
KeyName string `xml:"KeyInfo>KeyName,omitempty"`
|
||||
X509Certificate *SignatureX509Data `xml:"KeyInfo>X509Data,omitempty"`
|
||||
XMLName xml.Name `xml:"http://www.w3.org/2000/09/xmldsig# Signature"`
|
||||
SignedInfo SignedInfo
|
||||
SignatureValue string `xml:"SignatureValue"`
|
||||
KeyName string `xml:"KeyInfo>KeyName,omitempty"`
|
||||
X509Certificate *SignatureX509Data `xml:"KeyInfo>X509Data,omitempty"`
|
||||
}
|
||||
|
||||
// SignatureX509Data represents the <X509Data> element of <Signature>
|
||||
@@ -50,17 +57,21 @@ func DefaultSignature(pemEncodedPublicKey []byte) Signature {
|
||||
certStr := base64.StdEncoding.EncodeToString(pemBlock.Bytes)
|
||||
|
||||
return Signature{
|
||||
CanonicalizationMethod: Method{
|
||||
Algorithm: "http://www.w3.org/TR/2001/REC-xml-c14n-20010315",
|
||||
},
|
||||
SignatureMethod: Method{
|
||||
Algorithm: "http://www.w3.org/2000/09/xmldsig#rsa-sha1",
|
||||
},
|
||||
ReferenceTransforms: []Method{
|
||||
Method{Algorithm: "http://www.w3.org/2000/09/xmldsig#enveloped-signature"},
|
||||
},
|
||||
DigestMethod: Method{
|
||||
Algorithm: "http://www.w3.org/2000/09/xmldsig#sha1",
|
||||
SignedInfo: SignedInfo{
|
||||
CanonicalizationMethod: Method{
|
||||
Algorithm: "http://www.w3.org/TR/2001/REC-xml-c14n-20010315",
|
||||
},
|
||||
SignatureMethod: Method{
|
||||
Algorithm: "http://www.w3.org/2000/09/xmldsig#rsa-sha1",
|
||||
},
|
||||
Reference: Reference{
|
||||
ReferenceTransforms: []Method{
|
||||
Method{Algorithm: "http://www.w3.org/2000/09/xmldsig#enveloped-signature"},
|
||||
},
|
||||
DigestMethod: Method{
|
||||
Algorithm: "http://www.w3.org/2000/09/xmldsig#sha1",
|
||||
},
|
||||
},
|
||||
},
|
||||
X509Certificate: &SignatureX509Data{
|
||||
X509Certificate: certStr,
|
||||
|
||||
Reference in New Issue
Block a user