ced2e8779f
* feat: Allow detection of MITM HTTPS proxies like ZScaler For security purposes, Figma heavily restrics the origins that are allowed to load within our Electron app. Unfortunately some corporate environments use MITM proxies like ZScaler, which intercepts our connection to `https://www.figma.com` and serves a redirect to e.g. `https://gateway.zscloud.net` before finally redirecting back to `https://www.figma.com`. In order to detect this situation and handle it gracefully, we need to be able to know whether or not the certificate for our own origin (`https://www.figma.com`) is chained to a known root. We do this by exposesing `CertVerifyResult::is_issued_by_known_root`. If the certification verification passed without the certificate being tied to a known root, we can safely assume that we are dealing with a MITM proxy that has its root CA installed locally on the machine. This means that HTTPS can't be trusted so we might as well make life easier for corporate users by loosening our origin restrictions without any manual steps. * Tweak docs wording
52 lines
1.5 KiB
C++
52 lines
1.5 KiB
C++
// Copyright (c) 2019 GitHub, Inc.
|
|
// Use of this source code is governed by the MIT license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#ifndef SHELL_BROWSER_NET_CERT_VERIFIER_CLIENT_H_
|
|
#define SHELL_BROWSER_NET_CERT_VERIFIER_CLIENT_H_
|
|
|
|
#include <string>
|
|
|
|
#include "net/cert/x509_certificate.h"
|
|
#include "services/network/public/mojom/network_context.mojom.h"
|
|
|
|
namespace electron {
|
|
|
|
struct VerifyRequestParams {
|
|
std::string hostname;
|
|
std::string default_result;
|
|
int error_code;
|
|
scoped_refptr<net::X509Certificate> certificate;
|
|
scoped_refptr<net::X509Certificate> validated_certificate;
|
|
bool is_issued_by_known_root;
|
|
|
|
VerifyRequestParams();
|
|
VerifyRequestParams(const VerifyRequestParams&);
|
|
~VerifyRequestParams();
|
|
};
|
|
|
|
class CertVerifierClient : public network::mojom::CertVerifierClient {
|
|
public:
|
|
using CertVerifyProc =
|
|
base::RepeatingCallback<void(const VerifyRequestParams& request,
|
|
base::OnceCallback<void(int)>)>;
|
|
|
|
explicit CertVerifierClient(CertVerifyProc proc);
|
|
~CertVerifierClient() override;
|
|
|
|
// network::mojom::CertVerifierClient
|
|
void Verify(int default_error,
|
|
const net::CertVerifyResult& default_result,
|
|
const scoped_refptr<net::X509Certificate>& certificate,
|
|
const std::string& hostname,
|
|
int flags,
|
|
const absl::optional<std::string>& ocsp_response,
|
|
VerifyCallback callback) override;
|
|
|
|
private:
|
|
CertVerifyProc cert_verify_proc_;
|
|
};
|
|
|
|
} // namespace electron
|
|
|
|
#endif // SHELL_BROWSER_NET_CERT_VERIFIER_CLIENT_H_
|