iPhone和UIWebView:强制HTTPS(动态重写URL) [英] iPhone and UIWebView: Force HTTPS (rewrite URLs on the fly)

查看:121
本文介绍了iPhone和UIWebView:强制HTTPS(动态重写URL)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于Web的应用程序,它使用Cocoa / CocoaTouch的UIWebView。我想(需要?)强制所有HTTP连接到HTTPS。请注意,我感兴趣的是将初始登录URL强制为HTTPS,并将所有中间提取强制转换为HTTPS。动机:新技巧在实践中击败SSL sslstrip

I have a web based application that uses Cocoa/CocoaTouch's UIWebView. I want (need?) to force all HTTP connections to HTTPS. Note that I am interested in forcing the initial, landing URL to HTTPS and all the intermediate fetches to HTTPS also. Motivation: New Tricks for Defeating SSL in Practice and sslstrip.

是否可以将WebView配置为仅使用HTTPS? UIWebView文档没有甚至提到HTTPS。考虑到Apple不允许我在UIWebView中禁用JavaScript ,我怀疑我是否可以制作视图上的配置更改。

Is it possible to configure WebView to only use HTTPS? The UIWebView documentation does not even mention HTTPS. Considering Apple does not allow me to disable JavaScript in a UIWebView, I doubt I can make the configuration change on the view.

或者答案位于 NSURLRequest 中的某处NSURLConnection ,可能还委托方法?我读了网址加载系统概述,我看不到我能在哪里更改请求。

Or does the answer lie somewhere in NSURLRequest, NSURLConnection, and possibly delegate methods? I read URL Loading System Overview, and I don't see where I am able to change requests.

推荐答案

如果您想更改请求,您可以代理UIWebView,以便拦截所有请求,然后用https替换http,并从代理发出请求。这样做的一种方法是子类NSURLCache并覆盖方法cachedResponseForRequest。

If you want to change the request you can proxy UIWebView so all requests are intercepted and then replace http with https, and make the request from the proxy. One way of doing this would be to subclass NSURLCache and override the method cachedResponseForRequest.

这篇关于iPhone和UIWebView:强制HTTPS(动态重写URL)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆