electron/atom/browser/net/atom_cert_verifier.h

68 lines
1.9 KiB
C
Raw Normal View History

// Copyright (c) 2015 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ATOM_BROWSER_NET_ATOM_CERT_VERIFIER_H_
#define ATOM_BROWSER_NET_ATOM_CERT_VERIFIER_H_
#include <map>
2016-07-13 03:07:57 +00:00
#include <memory>
#include <string>
#include "net/cert/cert_verifier.h"
namespace atom {
class AtomCTDelegate;
class CertVerifierRequest;
struct VerifyRequestParams {
2017-02-08 00:35:37 +00:00
std::string hostname;
std::string default_result;
scoped_refptr<net::X509Certificate> certificate;
};
class AtomCertVerifier : public net::CertVerifier {
public:
explicit AtomCertVerifier(AtomCTDelegate* ct_delegate);
virtual ~AtomCertVerifier();
using VerifyProc = base::Callback<void(const VerifyRequestParams& request,
const net::CompletionCallback&)>;
2015-11-18 03:17:08 +00:00
void SetVerifyProc(const VerifyProc& proc);
const VerifyProc verify_proc() const { return verify_proc_; }
AtomCTDelegate* ct_delegate() const { return ct_delegate_; }
net::CertVerifier* default_verifier() const {
return default_cert_verifier_.get();
}
protected:
// net::CertVerifier:
2016-09-06 08:24:37 +00:00
int Verify(const RequestParams& params,
net::CRLSet* crl_set,
net::CertVerifyResult* verify_result,
const net::CompletionCallback& callback,
2016-05-23 01:59:39 +00:00
std::unique_ptr<Request>* out_req,
2017-01-24 05:17:43 +00:00
const net::NetLogWithSource& net_log) override;
bool SupportsOCSPStapling() override;
private:
friend class CertVerifierRequest;
void RemoveRequest(const RequestParams& params);
CertVerifierRequest* FindRequest(const RequestParams& params);
std::map<RequestParams, CertVerifierRequest*> inflight_requests_;
2015-11-18 03:17:08 +00:00
VerifyProc verify_proc_;
2016-05-23 01:59:39 +00:00
std::unique_ptr<net::CertVerifier> default_cert_verifier_;
AtomCTDelegate* ct_delegate_;
DISALLOW_COPY_AND_ASSIGN(AtomCertVerifier);
};
} // namespace atom
#endif // ATOM_BROWSER_NET_ATOM_CERT_VERIFIER_H_