通过 SSL (https) 使用 Monotouch 的 WCF 服务 +基本Http绑定
我目前正在编写一个 iPhone 应用程序,它将通过安全连接(SSL/https)使用 WCF 服务。我在通过 http 进行本地测试时成功地使用了该服务。
现在我们要确保服务是安全的,因此我们设置了一个带有正确签名证书的 UAT 服务器来运行我们的测试。
我们使用自定义绑定,并结合安全模式 TransportWithMessageCredentials
,该模式需要 ClientCredentials
属性中的用户名/密码。
使用 SISvcUtil.exe 生成代理
当我尝试从 iPhone 调用此安全服务时,我收到一个相当可爱的通用错误:
异步操作中的异常:System.Net.WebException:那里处理 Web 请求时出错:状态代码 500(内部服务器错误)
(这是一个完全例外的pastebin)。
我尝试使用以下方式隐式接受证书: ServicePointManager.ServerCertificateValidationCallBack = (发件人、证书、链、ssl) =>正确;
但这只会返回相同的 500 错误。
相同的代码在 Windows 机器上运行良好,但在 iPhone 上则不然。有其他人遇到过这个问题和/或知道解决方案吗?
I'm currently writing a iphone app which will consume WCF services over a secure connection (SSL/https). I have managed to consume this service while testing locally via http.
Now we want to make sure the service is secure, so we've set up a UAT server with a properly signed certificate to run our tests.
We are using a custom binding, coupled with security mode TransportWithMessageCredentials
which requires a username/password in the ClientCredentials
property.
Generated the proxy using SISvcUtil.exe
When I try to call this secure service from the iPhone, I get a rather lovely generic error of:
Exception in async operation: System.Net.WebException: There was an error on processing web request: Status code 500(internal server error)
(Here is a pastebin of full exception ).
I've tried implicitly accepting the certificate using:ServicePointManager.ServerCertificateValidationCallBack = (sender, cert, chain, ssl) => true;
but this just returns the same 500 error.
The same code works great on a windows machine but not on the iphone. Has anyone else come across this problem and/or know of a solution to it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这可能是 monotouch 中的一个错误,它可能没有使用 SISvcUtil.exe 生成代理的完整实现,您是否尝试生成 mac 应用程序并在 mac 上测试它?
monotouch 是否有支持 WCF 代理的文档示例?如果他们没有,那么它可能无法工作,monotouch 不提供 .NET 运行时,而是实际上将所有内容编译为本机 ios 二进制文件。所以如果WCF代理没有正确转换,它将无法工作。
This could be a bug in monotouch, it may not have full implementation of generated proxy using SISvcUtil.exe, did you try generating a mac app and test it on mac?
Does monotouch have any documented example with support on WCF proxy? If they dont have then probably it may not work, monotouch does not provide a .NET runtime, instead it actually compiles everything to native ios binary. So if WCF proxy is not correctly transformed, it will not work.
因此,在撰写本文时,Monotouch 似乎并不能很好地支持 WCF(它目前只有一个准系统实现)。
由于这一点,以及我们的网络服务需要良好的安全性,我们决定走另一条路;每次调用 Web 服务时,都会通过安全、加密的 SSL 连接通过用户名+密码验证用户。我们使用 Silverlight 3.0
SiSUtil.exe
生成 Web 服务的绑定,而不是将其作为 Web 引用包含在项目中。So it would seem that at the time of writing, Monotouch doesn't support WCF very well (it currently has a barebones implementation).
Due to this, and the need for decent security around our webservice, we've decided to go down a different route; validating the user via username+password over a secure, encrypted SSL connection everytime the web service is called. We use Silverlight 3.0
SiSUtil.exe
to generate the bindings for the webservice rather than include it as a web reference in the project.通常,当收到内部服务器错误时,我发现原因是请求中发送的 HTTP 标头出现问题。我并没有真正在 MonoTouch 上使用 WCF,所以我不确定其实现。
Generally when getting Internal Server errors I've found the cause to be a problem with the HTTP headers being sent in the request. I don't really use WCF on MonoTouch so I'm not sure about the implementation.