在 FiddlerScript 中定义“ClientCertificateProvider”

问题描述 投票:0回答:1

我想使用 FiddlerScript 为 Fiddler Classic 编写一个“ClientCertificateProvider”。

“FiddlerClientCertPicker”C# 扩展从 @EricLaw 转换为 JScript.NET 有点有效,但将我的代码连接到 FiddlerApplication.ClientCertificateProvider does 却没有。

在与 JScript.NET 语法斗争了相当长一段时间后;-) 这就是我正在尝试的:

import System;
import Fiddler;
import System.Net.Security;
import System.Security.Cryptography;  
import System.Security.Cryptography.X509Certificates;


class Handlers
{
    // *****************
    //
    // This is the Handlers class. Pretty much everything you ever add to FiddlerScript
    // belongs right inside here, or inside one of the already-existing functions below.
    //
    // *****************

[...]          

    
    static function ProvideClientCertificate(sender: Object, targetHost: String, 
                           localCertificates : X509CertificateCollection, 
                           remoteCertificate : X509Certificate, 
                           acceptableIssuers : String[]): X509Certificate {
        FiddlerObject.log("Client Certificate needed for " + targetHost);
        return (null);
    }

[...]
    static function Main() {
        var today: Date = new Date();
        FiddlerObject.StatusText = " CustomRules.js was loaded at: " + today;

        FiddlerApplication.Prefs.SetBoolPref("fiddler.network.https.clientcertificate.ephemeral.prompt-for-missing", false);

        FiddlerApplication.ClientCertificateProvider = ProvideClientCertificate;

这在语法上是正确的,但未显示日志条目。

更新:同时我发现了问题并在上面的代码中更正了它。

现在我在Fiddler的“Log”选项卡中看到了预期的结果:

Client Certificate needed for https//www.testservername.com 
fiddler jscript.net
1个回答
0
投票

我的代码中的问题是,ProvideClientCertificate() 函数的签名不正确。

正确的语法是:

    static function ProvideClientCertificate(sender: Object, targetHost: String, 
                           localCertificates : X509CertificateCollection, 
                           remoteCertificate : X509Certificate, 
                           acceptableIssuers : String[]): X509Certificate 

现在我在Fiddler的“Log”选项卡中看到了预期的结果:

Client Certificate needed for https//www.testservername.com 
© www.soinside.com 2019 - 2024. All rights reserved.