我不太确定如何将其转换为常规语法。

已经检查了此differences with java页。

谢谢!

    TrustManager[] trustAllCerts = new TrustManager[] {
       new X509TrustManager() {
          public java.security.cert.X509Certificate[] getAcceptedIssuers() {
            return null;
          }

          public void checkClientTrusted(X509Certificate[] certs, String authType) {  }

          public void checkServerTrusted(X509Certificate[] certs, String authType) {  }

       }
    };

最佳答案

以下应该工作:

import java.security.cert.*
import javax.net.ssl.*

TrustManager[] trustAllCerts = [
    [ getAcceptedIssuers: { -> null },
      checkClientTrusted: { X509Certificate[] certs, String authType -> },
      checkServerTrusted: { X509Certificate[] certs, String authType -> } ] as X509TrustManager
]

10-08 17:42