/// <summary> /// Создать сообщение с подписью (общий регламент) /// </summary> /// <param name="message"></param> /// <param name="document"></param> /// <param name="certificate"></param> /// <returns></returns> public Message CreateSign(Message message, Document document, X509Certificate2 certificate) { if (message == null) throw new ArgumentNullException("message"); if (document == null) throw new ArgumentNullException("document"); if (certificate == null) throw new ArgumentNullException("certificate"); if (document.Content == null) throw new ArgumentException("Содержимое документа не загружено"); var sign = CryptoApiHelper.Sign(certificate, document.Content, true); var signMessage = new Message() { Id = Guid.NewGuid().ToString(), From = CurrentBox, Recipients = message.GetRecipientListForSender(CurrentBox), Signs = new [] { new Sign() { DocumentId = document.Id, Raw = sign, Id = Guid.NewGuid().ToString() } } }; return signMessage; }
public Message CreateServiceDocumentMessage(Message message, Document document, X509Certificate2 certificate2, DocumentType documentType, NamedContent generatedNotice) { var noticeMessage = AddDocumentToNewMessage( new Message() { Id = Guid.NewGuid().ToString(), From = CurrentBox, Recipients = message.GetRecipientListForSender(CurrentBox), }, new Document() { Id = (Guid.NewGuid().ToString()), DocumentType = documentType, ParentDocumentId = document.Id, FileName = generatedNotice.Name, Content = generatedNotice.Content }, CryptoApiHelper.Sign(certificate2, generatedNotice.Content, true)); return noticeMessage; }