2015-11-05 14:06:36 +00:00
|
|
|
// Copyright (c) 2015 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2015-11-17 11:03:09 +00:00
|
|
|
#ifndef ATOM_BROWSER_NET_ATOM_CERT_VERIFIER_H_
|
|
|
|
#define ATOM_BROWSER_NET_ATOM_CERT_VERIFIER_H_
|
2015-11-05 14:06:36 +00:00
|
|
|
|
2016-11-09 13:05:46 +00:00
|
|
|
#include <map>
|
2016-07-13 03:07:57 +00:00
|
|
|
#include <memory>
|
2015-11-05 14:06:36 +00:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "net/cert/cert_verifier.h"
|
|
|
|
|
2017-11-15 13:09:22 +00:00
|
|
|
namespace brightray {
|
|
|
|
|
|
|
|
class RequireCTDelegate;
|
|
|
|
|
|
|
|
} // namespace brightray
|
|
|
|
|
2015-11-05 14:06:36 +00:00
|
|
|
namespace atom {
|
|
|
|
|
2016-11-09 13:05:46 +00:00
|
|
|
class CertVerifierRequest;
|
2016-10-17 10:33:24 +00:00
|
|
|
|
2017-02-08 18:34:07 +00:00
|
|
|
struct VerifyRequestParams {
|
2017-02-08 00:35:37 +00:00
|
|
|
std::string hostname;
|
|
|
|
std::string default_result;
|
2017-10-16 09:17:21 +00:00
|
|
|
int error_code;
|
2017-02-08 00:35:37 +00:00
|
|
|
scoped_refptr<net::X509Certificate> certificate;
|
2018-04-17 23:37:22 +00:00
|
|
|
|
|
|
|
VerifyRequestParams();
|
|
|
|
VerifyRequestParams(const VerifyRequestParams&);
|
|
|
|
~VerifyRequestParams();
|
2017-02-08 00:35:37 +00:00
|
|
|
};
|
|
|
|
|
2015-11-12 19:55:23 +00:00
|
|
|
class AtomCertVerifier : public net::CertVerifier {
|
2015-11-05 14:06:36 +00:00
|
|
|
public:
|
2017-11-15 13:09:22 +00:00
|
|
|
explicit AtomCertVerifier(brightray::RequireCTDelegate* ct_delegate);
|
2018-04-17 23:03:51 +00:00
|
|
|
~AtomCertVerifier() override;
|
2015-11-16 13:28:37 +00:00
|
|
|
|
2017-02-08 18:34:07 +00:00
|
|
|
using VerifyProc = base::Callback<void(const VerifyRequestParams& request,
|
2018-10-02 21:36:10 +00:00
|
|
|
net::CompletionOnceCallback)>;
|
2015-11-18 03:17:08 +00:00
|
|
|
|
|
|
|
void SetVerifyProc(const VerifyProc& proc);
|
2015-11-05 14:06:36 +00:00
|
|
|
|
2016-11-09 13:05:46 +00:00
|
|
|
const VerifyProc verify_proc() const { return verify_proc_; }
|
2017-11-15 13:09:22 +00:00
|
|
|
brightray::RequireCTDelegate* ct_delegate() const { return ct_delegate_; }
|
2016-11-09 13:05:46 +00:00
|
|
|
net::CertVerifier* default_verifier() const {
|
|
|
|
return default_cert_verifier_.get();
|
|
|
|
}
|
|
|
|
|
2015-11-12 19:55:23 +00:00
|
|
|
protected:
|
2015-11-05 14:06:36 +00:00
|
|
|
// net::CertVerifier:
|
2016-09-06 08:24:37 +00:00
|
|
|
int Verify(const RequestParams& params,
|
2015-11-05 14:06:36 +00:00
|
|
|
net::CRLSet* crl_set,
|
|
|
|
net::CertVerifyResult* verify_result,
|
2018-10-02 21:36:10 +00:00
|
|
|
net::CompletionOnceCallback 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;
|
2015-11-05 14:06:36 +00:00
|
|
|
|
|
|
|
private:
|
2016-11-09 13:05:46 +00:00
|
|
|
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_;
|
2017-11-15 13:09:22 +00:00
|
|
|
brightray::RequireCTDelegate* ct_delegate_;
|
2015-11-05 14:06:36 +00:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(AtomCertVerifier);
|
|
|
|
};
|
|
|
|
|
2018-04-18 01:44:10 +00:00
|
|
|
} // namespace atom
|
2015-11-05 14:06:36 +00:00
|
|
|
|
2015-11-17 11:03:09 +00:00
|
|
|
#endif // ATOM_BROWSER_NET_ATOM_CERT_VERIFIER_H_
|