add URI in Reference
This commit is contained in:
48
signature.go
48
signature.go
@@ -25,21 +25,22 @@ type Method struct {
|
|||||||
// buf, _ = Sign(key, buf)
|
// buf, _ = Sign(key, buf)
|
||||||
//
|
//
|
||||||
type Reference struct {
|
type Reference struct {
|
||||||
XMLName xml.Name `xml:"http://www.w3.org/2000/09/xmldsig# Reference"`
|
|
||||||
URI string `xml:",attr"`
|
URI string `xml:",attr"`
|
||||||
Transforms []Method `xml:"Transforms>Transform"`
|
Transforms []Method `xml:"Transforms>Transform"`
|
||||||
DigestMethod Method `xml:"DigestMethod"`
|
DigestMethod Method
|
||||||
DigestValue string `xml:"DigestValue"`
|
DigestValue string
|
||||||
|
}
|
||||||
|
type SignedInfo struct {
|
||||||
|
CanonicalizationMethod Method `xml:"CanonicalizationMethod"`
|
||||||
|
SignatureMethod Method `xml:"SignatureMethod"`
|
||||||
|
Reference Reference
|
||||||
}
|
}
|
||||||
type Signature struct {
|
type Signature struct {
|
||||||
XMLName xml.Name `xml:"http://www.w3.org/2000/09/xmldsig# Signature"`
|
XMLName xml.Name `xml:"http://www.w3.org/2000/09/xmldsig# Signature"`
|
||||||
|
SignedInfo SignedInfo
|
||||||
CanonicalizationMethod Method `xml:"SignedInfo>CanonicalizationMethod"`
|
SignatureValue string `xml:"SignatureValue"`
|
||||||
SignatureMethod Method `xml:"SignedInfo>SignatureMethod"`
|
KeyName string `xml:"KeyInfo>KeyName,omitempty"`
|
||||||
Reference Reference `xml:"http://www.w3.org/2000/09/xmldsig# Reference"`
|
X509Certificate *SignatureX509Data `xml:"KeyInfo>X509Data,omitempty"`
|
||||||
SignatureValue string `xml:"SignatureValue"`
|
|
||||||
KeyName string `xml:"KeyInfo>KeyName,omitempty"`
|
|
||||||
X509Certificate *SignatureX509Data `xml:"KeyInfo>X509Data,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SignatureX509Data represents the <X509Data> element of <Signature>
|
// SignatureX509Data represents the <X509Data> element of <Signature>
|
||||||
@@ -55,19 +56,20 @@ func DefaultSignature(pemEncodedPublicKey []byte) Signature {
|
|||||||
certStr := base64.StdEncoding.EncodeToString(pemBlock.Bytes)
|
certStr := base64.StdEncoding.EncodeToString(pemBlock.Bytes)
|
||||||
|
|
||||||
return Signature{
|
return Signature{
|
||||||
CanonicalizationMethod: Method{
|
SignedInfo: SignedInfo{
|
||||||
Algorithm: "http://www.w3.org/TR/2001/REC-xml-c14n-20010315",
|
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{
|
|
||||||
URI: "#pfxd0b69e8d-7ef1-bc79-e854-76787764d7ee",
|
|
||||||
Transforms: []Method{
|
|
||||||
Method{Algorithm: "http://www.w3.org/2000/09/xmldsig#enveloped-signature"},
|
|
||||||
},
|
},
|
||||||
DigestMethod: Method{
|
SignatureMethod: Method{
|
||||||
Algorithm: "http://www.w3.org/2000/09/xmldsig#sha1",
|
Algorithm: "http://www.w3.org/2000/09/xmldsig#rsa-sha1",
|
||||||
|
},
|
||||||
|
Reference: Reference{
|
||||||
|
Transforms: []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: &SignatureX509Data{
|
||||||
|
|||||||
Reference in New Issue
Block a user