![](/img/trans.png)
[英]Decrypt a blob from Azure blob storage with key vault using version 12.x Azure storage libraries
[英]Decrypt WCF callback with Certificate from Azure Blob Storage
我是WCF的新手,我正在使用customBinding(他們不是我的)使用安全的WCF服務。
var sbe = SecurityBindingElement.CreateMutualCertificateDuplexBindingElement(MessageSecurityVersion.WSSecurity10WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecurityProfile10);
sbe.EndpointSupportingTokenParameters.Signed.Add(new UserNameSecurityTokenParameters());
sbe.MessageSecurityVersion = MessageSecurityVersion.WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10;
sbe.DefaultAlgorithmSuite = SecurityAlgorithmSuite.Basic256Rsa15;
sbe.AllowSerializedSigningTokenOnReply = true;
sbe.IncludeTimestamp = true;
sbe.SecurityHeaderLayout = SecurityHeaderLayout.Lax;
sbe.MessageProtectionOrder = MessageProtectionOrder.EncryptBeforeSign;
編輯:
決定簡化新要求以確定是否有幫助。
我想有一個回調端點,它使用單個合同並使用上面的綁定。 問題是發送到此服務的郵件將由不同的證書(我們的客戶端公共證書)加密。
我不希望有數百個端點,我可以明確指定用於解密的證書,因為我們可能需要修改/添加/刪除,因為我已經發現,你不能在serviceHost打開后執行此操作我們無法服務下來/重啟它。
是否有可能攔截消息,解密並以某種方式傳遞它? (我現在正在查看消息攔截,看看這是否可行)。
消息攔截和解密
請參閱此鏈接使用WCF解密安全令牌
在處理相互證書身份驗證時,您擁有客戶端證書的私鑰。
使用Message Inspectors,可以攔截傳入的消息,並使用客戶端證書的私鑰對其進行解密。
在WCF服務的使用者端使用AfterReceiveReply事件來覆蓋WCF中的解密邏輯
public void AfterReceiveReply(ref Message reply, object correlationState)
{}
Message Inspectors必須包含在配置文件的綁定擴展中
<extensions>
<behaviorExtensions>
<add name="customMessageInspector" type="WCFComponents.CustomMessageInspector.CustomMessageInspectorBehaviorElement, WCFComponents"/>
</behaviorExtensions>
</extensions>
並且此行為必須包含在WCF代理端點行為中
var behavior = new CustomMessageInspectorBehavior();
_serviceProxy.Endpoint.Behaviors.Add(behavior);
在此處下載示例WCF消息檢查器項目
您必須執行WCF自定義才能實現此目的。
希望這可以幫助
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.