private string SignHashOnServer(byte[] hash) { var certificate = CertificateHelper.GetCertificateByThumbprint(TestIntegrationClientServer.CERTIFICATE_THUMBPRINT); Assert.IsNotNull(certificate); var gost = (Gost3410CryptoServiceProvider)certificate.PrivateKey; var secureString = new SecureString(); foreach (var ch in TestIntegrationClientServer.PRIVATE_KEY_PASSWORD) { secureString.AppendChar(ch); } #pragma warning disable 612 SignatureDescription signDescr = (SignatureDescription)CryptoConfig.CreateFromName(CPSignedXml.XmlDsigGost3410UrlObsolete); #pragma warning restore 612 var base64String = Convert.ToBase64String(signDescr.CreateFormatter(gost).CreateSignature(hash)); return(base64String); }
private XadesSignedXml GetXadesSignedXml(XadesInfo xadesInfo, XmlDocument originalDoc) { var certificate = CertificateHelper.GetCertificateByThumbprint(TestIntegrationClientServer.CERTIFICATE_THUMBPRINT); Assert.IsNotNull(certificate); var signatureid = String.Format("xmldsig-{0}", Guid.NewGuid().ToString().ToLower()); var xadesSignedXml = GisSignatureHelper.GetXadesSignedXml(certificate, originalDoc, signatureid, TestIntegrationClientServer.PRIVATE_KEY_PASSWORD); var keyInfo = GisSignatureHelper.GetKeyInfo(xadesInfo.RawPK); xadesSignedXml.KeyInfo = keyInfo; var xadesObject = GisSignatureHelper.GetXadesObject(xadesInfo, signatureid); var signTimeStr = xadesObject.QualifyingProperties.SignedProperties.SignedSignatureProperties.SigningTime.ToString("yyyy-MM-ddTHH:mm:ss.fffzzz"); Console.WriteLine(signTimeStr); Assert.IsTrue(signTimeStr.Contains("+09")); xadesSignedXml.AddXadesObject(xadesObject); return(xadesSignedXml); }