Web 浏览器控制 - 页面加密
我正在开发一个使用内置网络浏览器控件的应用程序。此应用程序将使用对称密钥来加密和解密 http 内容。因此,在网页浏览器控件中显示网页之前,将使用对称密钥对其进行解密。例如:
我想导航到 www.abc.com,并且该网站的内容是使用对称密钥保护的,我的代码是:
webBrowser.navigate("http://www.abc.com"); -- to navigate to the website
但是我如何获取该网站的内容,解密并将其显示给网络浏览器?
I'm developing an app that use built in Web Browser control. This app will use a symmetric key to encrypt and decrypt http content. So, before a web page is shown in the web browser control, it would be decrypted using the symmetric key. For example:
I want to navigate to www.abc.com, and the content of this website is secured using symmetric key, my code would be:
webBrowser.navigate("http://www.abc.com"); -- to navigate to the website
but how am I going to get the content of that website, decrypt it and show it to the web browser?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 C#.NET 中使用标准 WebBrowser 控件,我不知道有一种简单的方法,您可以只获取“显示的”加密 HTML/图像/样式表/等,并在控件/用户查看它之前使用您自己的方法解密流。
根据您的评论,这是一个研究项目,不适用于现实世界(我同意 Shaun go with SSL/client certs),这里有一些想法:
在您的 C# 中实现本地代理服务进行解密。然后将您的 Internet Explorer 代理设置指向该地址(例如 http://127.0.0.1:8080),如 C# .NET WebBrowser 控件使用 IE 设置。
如果您只加密页面上的一小部分内容(例如某些文本?),那么您可以让网页将加密代码封装在一些 JavaScript 中,以访问您的本地 C#.NET 解密代码。这可以通过设置 webBrowser1.ObjectForScripting = new yourDecryptClass() 将 JavaScript 的 document.external 映射到您选择的类来完成
Using the standard WebBrowser control in C#.NET I'm not aware of a simple way you could just take the "displayed" encrypted HTML/images/stylesheets/etc and decrypt the stream using your own method before the control/user views it.
Based on your comment that is is a research project and not for real world use (I'd agree with Shaun go with SSL/client certs), here are a couple of ideas:
Implement a local Proxy Service in your C# that does the decryption. Then point your Internet Explorer proxy setting to that (e.g. http://127.0.0.1:8080), as the C#.NET WebBrowser control uses the IE settings.
If you're only encrypting small pieces of content (e.g. some text?) on your page then you could have your webpage wrap the encrypted code within some JavaScript that accesses your local C#.NET decryption code. This can be done by mapping JavaScript's document.external to a class of your choice by setting webBrowser1.ObjectForScripting = new yourDecryptClass()