내가 onLocationChange를 사용하여 HTTPS 페이지로드를 가로채는 해킹 솔루션을 개발할 것입니다. 아직 완벽하지 않을 수도 있습니다.
새 탭에서 링크를 열 때 이벤트가 제대로 시작되지 않았기 때문에 onSecurityChange (내 질문에 설명 된대로)를 사용할 수 없었습니다.
onLocationChange: function(aBrowser, aWebProgress, aRequest, aLocation, aFlags) {
if(aRequest != null) {
// suspend early, because that becomes impossible later
aRequest.suspend();
// check if it is HTTPS (no HTTP, no about:, etc.)
if(aLocation.scheme == "https") {
var whateverIWantToDo = {
notify: function(timer) {
try {
// for example I'm interested in the validation result:
let secUI = aBrowser.securityUI;
secUI.QueryInterface(Components.interfaces.nsISSLStatusProvider);
let status = secUI.SSLStatus;
// do something what you want here
// and do not forget to resume the request at any point. otherwise that could lead to problems
aRequest.resume();
//....
// the reason I suspend the request at all:
// I do not want to completely load the page until I know if the certificate is valid
}
catch(err) {
// maybe it's too early to access the SSLStatus when the event handler kicks in.
// in this case an error will be thrown which is caught here
// wait 10 ms and try it again, usually that works! (I know, it's a bit hacky)
var timer = Components.classes["@mozilla.org/timer;1"].createInstance(Components.interfaces.nsITimer);
timer.initWithCallback(whateverIWantToDo, 10, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
}
}
}
whateverIWantToDo.notify();
} else {
// continue normally when it's not a HTTPS request, we want to intercept
aRequest.resume();
}
}
}
가장 쉬운 것 같아서 첫 번째 옵션을 선호합니다. 하지만 onStateChange 내의 Firefox/NSS에서 SSL 검증 결과를 얻을 수 있습니까? onSecurityChange에는이 정보를 검색 할 수있는 aState 객체가 있습니다. – firefexx
나는 그걸로 놀아야 만 할 지 확신하지 못합니다. 우리가 배우고있는 것을 배운다. 여기도 배우고있다. – Noitidart
그것은 변하지 않는 것처럼 보인다. 쓸모가 없다. google.de를 입력하면 두 개의 onStateChange 이벤트가 발생합니다. 하나의 STATE_START는 request.name = 'http : // www.google.de' (HTTPS 없음)이고 하나의 STATE_STOP은 request.name ='https : // www.google.de'입니다 (HTTPS 사용). STOP이 너무 늦어서 HTTP 페이지에서 리디렉션 될 때 START가 HTTPS에 대해 실행되지 않으므로 인증서로 아무 것도 할 수 없습니다. ..... HTTPS 페이지가로드 될 때마다 무언가를 수행하는 간단한 방법이 아닙니까? – firefexx