简体   繁体   English

如何在客户端(DataServiceContext)加密OData请求有效负载并在ServerSide解密请求?

[英]How could I Encrypt OData Request Payload at Client Side(DataServiceContext) and Decrypting Request at ServerSide?

I have an Windows Application consuming OData v4 WebAPI using DataServiceContext . 我有一个Windows应用程序,它使用DataServiceContext来使用OData v4 WebAPI。 WebApi is over SSL but still I think anyone can trap request using Web Debugging Tools like fiddler (on the Windows Application Host Machine) and can re-issue the request by altering Request Body. WebApi是基于SSL的,但是我仍然认为任何人都可以使用诸如Fiddler之类的Web调试工具(在Windows应用程序主机上)来捕获请求,并可以通过更改请求主体来重新发出请求。

So I was just thinking what if I could encrypt RequestBody of outgoing Request in Windows Application using Public/Private Key in Production Environment. 所以我只是在想如果可以在生产环境中使用公钥/私钥对Windows应用程序中的传出请求的RequestBody进行加密。 If yes how could I? 如果可以,我该怎么办?

Do I need to create custom DataServiceClientRequestMessage or need to hook encryption process somewhere in DataServiceContext . 我需要创建自定义DataServiceClientRequestMessage还是需要在DataServiceContext中的某个地方挂接加密过程。

The Request would be decrypted using MessageHandler . 该请求将使用MessageHandler解密。

ServiceStack Encrypted Messaging ServiceStack加密消息

Yes, I think you can write your custom DataServiceClientRequestMessage , and overwrite GetStream() to encrypt the output stream. 是的,我认为您可以编写自定义DataServiceClientRequestMessage并覆盖GetStream()来加密输出流。 Then, set the new message to DataServiceContext with DataServiceContext.Configurations.RequestPipeline.OnMessageCreating = new CustomRequestMessage() . 然后,使用DataServiceContext.Configurations.RequestPipeline.OnMessageCreating = new CustomRequestMessage()将新消息设置为DataServiceContext。

You can refer a custom DataServiceClientRequestMessage example at OData github repository. 您可以在OData github存储库中引用自定义DataServiceClientRequestMessage示例。 TestDataServiceClientRequestMessage.cs and DataServiceContextWithCustomTransportLayer.cs TestDataServiceClientRequestMessage.csDataServiceContextWithCustomTransportLayer.cs

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在DataServiceContext WCF数据服务客户端中解码gzip? - How can I decode gzip in a DataServiceContext WCF Data Services client? wcf odata客户端-如何忽略请求中的空属性 - wcf odata client - how to ignore null properties in request 简单 Odata 客户端 - 如何在每个请求标头中添加 oAuth 令牌? - Simple Odata Client - How to add oAuth Token in each request header? 如何在Advanced Rest Client中将字典作为POST请求中有效负载的一部分传递 - How to pass dictionary as part of the payload in POST request in Advanced Rest Client 如何在客户端设置请求主体 - How to set the request body on the client side DataServiceContext.SaveChanges() 抛出 Microsoft.OData.Client.DataServiceRequestException - DataServiceContext.SaveChanges() throws Microsoft.OData.Client.DataServiceRequestException 启动后但上载请求有效负载之前,如何拦截(服务器端)非流HTTP WCF请求 - How to intercept (server side) a non-streaming HTTP WCF request after it is started but before the request payload is uploaded OData Simple.OData.Client V3发送其他请求 - OData Simple.OData.Client V3 sends other request 如何记录来自客户端的完整的原始WCF客户端请求? - How to log full raw WCF client request from client side? 如何将有效负载附加到RestSharp请求中? - How to attach payload into RestSharp request?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM