SWT-Browser:如果证书不受信任,如何使用HTTPS加载资源? [英] SWT-Browser: How to load a resource using HTTPS if the certificate is untrusted?

查看:251
本文介绍了SWT-Browser:如果证书不受信任,如何使用HTTPS加载资源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用SWT浏览器小部件通过HTTPS加载网络摄像头服务器的图像.遗憾的是,摄像头服务器证书是不受信任的.我尝试了2种变体来加载图像:

I am using the SWT Browser Widget to load the image of a webcam-server via HTTPS. Sadly the webcam-server certificate is untrusted. I tried to 2 variants to load the image:

  1. Browser.setHTML(String)
    每秒使用HTML + JavaScript加载图像.这是避免闪烁的首选方法.如果我有HTTPS连接,这对于HTTP来说效果很好,但我的替代文字除外.
  2. Browser.setUrl(String)
    通过每秒设置URL来加载图像.由于重新加载,这会导致整体闪烁,这是不可接受的.我尝试了所有可用的SWT浏览器的此变体.如果我使用SWT.WEBKITSWT.MOZILLA(XulRunner),则根本没有机会获得图像.会弹出一个对话框,告诉我该证书不受信任,没有选择接受的选项.如果我使用SWT.NONE,则使用IE(我在WinXP上),然后弹出对话框询问我是否要信任证书,按OK后,我可以看到图像.
  1. Browser.setHTML(String)
    Load the image using HTML+JavaScript every second. This is the prefered way to avoid flickering. This works very fine for HTTP, if i have a HTTPS connection i will see noting at all except my alternative text.
  2. Browser.setUrl(String)
    Load the image by setting the URL every second. This causes massiv flickering because of the reload, wich is unacceptable. I tried this variant with all available SWT-Browsers. If i use SWT.WEBKIT or SWT.MOZILLA (XulRunner) i have no chance at all to get the image. An dialog pop up and tell me the certificate is untrusted with no option to accept it. If i use SWT.NONE the IE is used (i am on WinXP) and the pop-up dialog ask if i want to trust the cert, after pressing OK i can see the image.

在这里,我在Stackoverflow上发现: how-to -ssl-certificate-file-with-swt-browser 导入. 但是我无法在我的XULRunner中找到 cert_override.txt ,而且我无法找到个人安全管理器(与许多其他工具一样)的下载链接!

Here at Stackoverflow i found: how-to-import-a-ssl-certificate-file-with-swt-browser. But i unable to find the cert_override.txt in my XULRunner, and i am unable to find a download link for the Personal Security Manager (like many others) !

我该如何允许不受信任的证书,使用变体1和XULRunner又名MOZILLA?是否可以通过编程方式进行?

How can i allow the untrusted certificate, use variant 1 and XULRunner aka MOZILLA ? Is it possible to do it programmatically ?

推荐答案

cert_override.txt位于用户的个人资料中.在Windows上,XULRunner用户配置文件的目录为%APPDATA%\<vendor>\<product>\Profiles\<something>.default,在OS X /Library/Application Support/<product>/Profiles/<something>.default上,在Linux ~/.<vendor>/<product>/Profiles/<something>.default上.在运行时,您可以使用nsIDirectoryService 来查找目录(ProfD是此目录的键)

cert_override.txt is located in the user's profile. On Windows the directory for XULRunner's user profiles is %APPDATA%\<vendor>\<product>\Profiles\<something>.default, on OS X /Library/Application Support/<product>/Profiles/<something>.default, on Linux ~/.<vendor>/<product>/Profiles/<something>.default. At runtime you can use nsIDirectoryService to locate the directory (ProfD is the key for this directory).

您可以直接从应用程序写入用户的配置文件,也可以将cert_override.txt的副本添加到XULRunner应用程序中,以将其复制到创建的所有用户配置文件中(必须将其放置在XULRunner应用程序的defaults/profile/cert_override.txt下)目录).请注意,后者只会影响正在创建的新配置文件,而不会影响已经存在的配置文件.

You can either write to the user's profile directly from your application or add a copy of cert_override.txt to your XULRunner application to be copied into all user profiles created (it would have to be put under defaults/profile/cert_override.txt in the XULRunner application directory). Note that the latter will only have an effect on new profiles being created, not on profiles that already exist.

顺便说一句,创建cert_override.txt文件的最简单方法是在Firefox中接受不受信任的证书,然后将条目从Firefox配置文件复制到XULRunner配置文件.

Btw, the simplest way to create a cert_override.txt file would be accepting an untrusted certificate in Firefox and then copying the entry from the Firefox profile to the XULRunner profile.

这篇关于SWT-Browser:如果证书不受信任,如何使用HTTPS加载资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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