/// <summary> /// Signs the electronic invoice using the given certificate & RSA key. /// </summary> /// <param name="certificate">The certificate.</param> /// <param name="key">The RSA Key.</param> /// <param name="signerRole">Rol del "firmante" de la factura</param> /// <returns>The XAdES signature verifier.</returns> private XAdESSignatureVerifier Sign(X509Certificate2 certificate, RSA key, ClaimedRole signerRole) { if (certificate == null) { throw new ArgumentNullException("certificate cannot be null"); } if (key == null) { throw new ArgumentNullException("key cannot be null"); } var document = this.ToXmlDocument(); var signedXml = new XAdESSignedXml(document); // Set the key to sign signedXml.SigningKey = key; signedXml.SetSignatureInfo() .SetSignerRole(signerRole) // XAdES Signer Role .SetKeyInfo(certificate, (RSA)certificate.PublicKey.Key) // Key Info .ComputeSignature(); // Compute Signature // Import the signed XML node document.DocumentElement.AppendChild(document.ImportNode(signedXml.GetXml(), true)); return(new XAdESSignatureVerifier(document)); }
/// <summary> /// Signs the electronic invoice using the given certificate & RSA key. /// </summary> /// <param name="certificate">The certificate.</param> /// <param name="key">The RSA Key.</param> /// <param name="signerRole">Rol del "firmante" de la factura</param> /// <returns>The XAdES signature verifier.</returns> public XAdESSignatureVerifier Sign(X509Certificate2 certificate, ClaimedRole signerRole) { if (certificate == null) { throw new ArgumentNullException("certificate cannot be null"); } return(this.Sign(certificate, (RSA)certificate.PrivateKey, signerRole)); }
public static SignedSignaturePropertiesType SetSignerRole(this SignedSignaturePropertiesType signedSignatureProperties , ClaimedRole signerRole) { signedSignatureProperties.SignerRole = new SignerRoleType { ClaimedRoles = new List <ClaimedRole> { signerRole } }; return(signedSignatureProperties); }
public static SignedSignaturePropertiesType SetSignerRole(this SignedSignaturePropertiesType signedSignatureProperties , ClaimedRole signerRole) { signedSignatureProperties.SignerRole = new SignerRoleType { ClaimedRoles = new List<ClaimedRole> { signerRole } }; return signedSignatureProperties; }
/// <summary> /// Signs the electronic invoice using the given certificate & RSA key. /// </summary> /// <param name="certificate">The certificate.</param> /// <param name="key">The RSA Key.</param> /// <param name="signerRole">Rol del "firmante" de la factura</param> /// <returns>The XAdES signature verifier.</returns> private XAdESSignatureVerifier Sign(X509Certificate2 certificate, RSA key, ClaimedRole signerRole) { if (certificate == null) { throw new ArgumentNullException("certificate cannot be null"); } if (key == null) { throw new ArgumentNullException("key cannot be null"); } var document = this.ToXmlDocument(); var signedXml = new XAdESSignedXml(document); // Set the key to sign signedXml.SigningKey = key; signedXml.SetSignatureInfo() .SetSignerRole(signerRole) // XAdES Signer Role .SetKeyInfo(certificate, (RSA)certificate.PublicKey.Key) // Key Info .ComputeSignature(); // Compute Signature // Import the signed XML node document.DocumentElement.AppendChild(document.ImportNode(signedXml.GetXml(), true)); return new XAdESSignatureVerifier(document); }
/// <summary> /// Signs the electronic invoice using the given certificate & RSA key. /// </summary> /// <param name="certificate">The certificate.</param> /// <param name="key">The RSA Key.</param> /// <param name="signerRole">Rol del "firmante" de la factura</param> /// <returns>The XAdES signature verifier.</returns> public XAdESSignatureVerifier Sign(X509Certificate2 certificate, ClaimedRole signerRole) { if (certificate == null) { throw new ArgumentNullException("certificate cannot be null"); } return this.Sign(certificate, (RSA)certificate.PrivateKey, signerRole); }
public XAdESSignedXml SetSignerRole(ClaimedRole signerRole) { this.signerRole = signerRole; return(this); }
public XAdESSignedXml SetSignerRole(ClaimedRole signerRole) { this.signerRole = signerRole; return this; }