Добрый день,
есть следующий рабочий код для подписи SOAP сообщений для общения с сервисом WCF
Код:
private static CustomBinding CreateCustomBinding(Binding binding, bool withSecurity) {
var customBinding = new CustomBinding(binding);
if (withSecurity) {
customBinding.Elements.Remove<SymmetricSecurityBindingElement>();
customBinding.Elements.Remove<AsymmetricSecurityBindingElement>();
var securityBindingElement =
(AsymmetricSecurityBindingElement)
SecurityBindingElement.CreateMutualCertificateBindingElement(
MessageSecurityVersion.WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10);
securityBindingElement.SetKeyDerivation(false);
securityBindingElement.EnableUnsecuredResponse = true;
securityBindingElement.AllowInsecureTransport = true;
securityBindingElement.AllowSerializedSigningTokenOnReply = true;
securityBindingElement.DefaultAlgorithmSuite = GostAlgorithmSuite.BasicGost;
securityBindingElement.IncludeTimestamp = false;
securityBindingElement.MessageProtectionOrder = MessageProtectionOrder.SignBeforeEncrypt;
securityBindingElement.RequireSignatureConfirmation = false;
securityBindingElement.SecurityHeaderLayout = SecurityHeaderLayout.LaxTimestampFirst;
customBinding.Elements.Insert(0, securityBindingElement);
}
var channelBindingElement = new StrippingChannelBindingElement();
customBinding.Elements.Insert(customBinding.Elements.Count - 1, channelBindingElement);
return customBinding;
}
но одном из серверов он падает с ошибкой:
Server stack trace:
в CryptoPro.Sharpei.COMCryptography.AcquireCSP(CspParameters param, SafeProvHandleCP& hProv)
в CryptoPro.Sharpei.CPUtils.AcquireProvHandle(CspParameters parameters)
в CryptoPro.Sharpei.CPUtils.get_StaticGost2012_256ProvHandle()
в CryptoPro.Sharpei.Gost28147CryptoServiceProvider.GenerateKey()
в CryptoPro.Sharpei.ServiceModel.CPWrappedKeySecurityToken.Detour..ctor(String id, Byte[] keyToWrap, String wrappingAlgorithm, XmlDictionaryString wrappingAlgorithmDictionaryString)
в System.ServiceModel.Security.Tokens.WrappedKeySecurityToken..ctor(String id, Byte[] keyToWrap, String wrappingAlgorithm, XmlDictionaryString wrappingAlgorithmDictionaryString, SecurityToken wrappingToken, SecurityKeyIdentifier wrappingTokenReference, Byte[] wrappedKey, SecurityKey wrappingSecurityKey)
в CryptoPro.Sharpei.ServiceModel.CPWrappedKeySecurityToken.Detour..ctor(String id, Byte[] keyToWrap, String wrappingAlgorithm, XmlDictionaryString wrappingAlgorithmDictionaryString, SecurityToken wrappingToken, SecurityKeyIdentifier wrappingTokenReference, Byte[] wrappedKey, SecurityKey wrappingSecurityKey)
в System.ServiceModel.Security.SendSecurityHeader.StartEncryption()
в CryptoPro.Sharpei.ServiceModel.CPSendSecurityHeader.StartEncryption()
в System.ServiceModel.Security.SendSecurityHeader.StartSecurityApplication()
в System.ServiceModel.Security.SecurityAppliedMessage.OnWriteMessage(XmlDictionaryWriter writer)
в System.ServiceModel.Channels.BufferedMessageWriter.WriteMessage(Message message, BufferManager bufferManager, Int32 initialOffset, Int32 maxSizeQuota)
в System.ServiceModel.Channels.TextMessageEncoderFactory.TextMessageEncoder.WriteMessage(Message message, Int32 maxMessageSize, BufferManager bufferManager, Int32 messageOffset)
в System.ServiceModel.Channels.HttpOutput.SerializeBufferedMessage(Message message, Boolean shouldRecycleBuffer)
в System.ServiceModel.Channels.HttpOutput.Send(TimeSpan timeout)
в System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.SendRequest(Message message, TimeSpan timeout)
в System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
в N3.Encryption.Stripping.StrippingRequestChannel.Request(Message message, TimeSpan timeout) в D:\n3zdrav\ips\N3.Encryption\Stripping\StrippingRequestChannel.cs:строка 47
в System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.Request(Message message, TimeSpan timeout)
в System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
в System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
в System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
в System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
в System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
в System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
в FerConnector.mis.misInterface.Send(SendRequest request)
в FerConnector.mis.misInterfaceClient.FerConnector.mis.misInterface.Send(SendRequest request) в D:\n3zdrav\fer21\FerV2\Proxy\FerConnector\Service References\mis\Reference.cs:строка 713
в Infrastructure.Services.Fer.FerServiceBase.Send(String messageCode, String message) в D:\n3zdrav\fer21\FerV2\Infrastructure\Infrastructure\Services\Fer\FerServiceBase.cs:строка 98
2016-11-14 14:40:21.8344 FATAL [1] FerApp.Program.Main: Общая ошибка System.Security.Cryptography.CryptographicException
Тип поставщика не определен.
подскажите в чем может быть проблема?
osinfo.xml
(66kb) загружен 1 раз(а).