2018-04-20 01:11:55 +08:00
|
|
|
/*
|
|
|
|
* FDBLibTLSPolicy.h
|
|
|
|
*
|
|
|
|
* This source file is part of the FoundationDB open source project
|
|
|
|
*
|
|
|
|
* Copyright 2013-2018 Apple Inc. and the FoundationDB project authors
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2018-04-13 03:28:52 +08:00
|
|
|
|
|
|
|
#ifndef FDB_LIBTLS_POLICY_H
|
|
|
|
#define FDB_LIBTLS_POLICY_H
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2018-10-20 09:53:09 +08:00
|
|
|
#include "fdbrpc/ITLSPlugin.h"
|
2019-05-21 06:12:28 +08:00
|
|
|
#include "flow/FastRef.h"
|
2018-04-13 03:28:52 +08:00
|
|
|
|
2018-10-20 09:53:09 +08:00
|
|
|
#include "FDBLibTLS/FDBLibTLSPlugin.h"
|
|
|
|
#include "FDBLibTLS/FDBLibTLSVerify.h"
|
2018-05-09 07:27:21 +08:00
|
|
|
|
2018-04-13 03:28:52 +08:00
|
|
|
#include <string>
|
2018-05-09 07:27:21 +08:00
|
|
|
#include <vector>
|
2018-04-13 03:28:52 +08:00
|
|
|
|
|
|
|
struct FDBLibTLSPolicy: ITLSPolicy, ReferenceCounted<FDBLibTLSPolicy> {
|
2018-07-12 09:41:46 +08:00
|
|
|
FDBLibTLSPolicy(Reference<FDBLibTLSPlugin> plugin);
|
2018-04-13 03:28:52 +08:00
|
|
|
virtual ~FDBLibTLSPolicy();
|
|
|
|
|
|
|
|
virtual void addref() { ReferenceCounted<FDBLibTLSPolicy>::addref(); }
|
|
|
|
virtual void delref() { ReferenceCounted<FDBLibTLSPolicy>::delref(); }
|
|
|
|
|
|
|
|
Reference<FDBLibTLSPlugin> plugin;
|
|
|
|
|
2018-05-09 07:27:21 +08:00
|
|
|
virtual ITLSSession* create_session(bool is_client, const char* servername, TLSSendCallbackFunc send_func, void* send_ctx, TLSRecvCallbackFunc recv_func, void* recv_ctx, void* uid);
|
2018-04-13 03:28:52 +08:00
|
|
|
|
2018-05-09 07:27:21 +08:00
|
|
|
struct stack_st_X509* parse_cert_pem(const uint8_t* cert_pem, size_t cert_pem_len);
|
2018-04-13 03:28:52 +08:00
|
|
|
void parse_verify(std::string input);
|
|
|
|
void reset_verify(void);
|
|
|
|
|
2018-05-09 07:27:21 +08:00
|
|
|
virtual bool set_ca_data(const uint8_t* ca_data, int ca_len);
|
2018-04-13 03:28:52 +08:00
|
|
|
virtual bool set_cert_data(const uint8_t* cert_data, int cert_len);
|
2018-05-09 07:27:21 +08:00
|
|
|
virtual bool set_key_data(const uint8_t* key_data, int key_len, const char* password);
|
|
|
|
virtual bool set_verify_peers(int count, const uint8_t* verify_peers[], int verify_peers_len[]);
|
2018-04-13 03:28:52 +08:00
|
|
|
|
2018-05-09 07:27:21 +08:00
|
|
|
struct tls_config* tls_cfg;
|
2018-04-13 03:28:52 +08:00
|
|
|
|
|
|
|
bool session_created;
|
|
|
|
|
2018-05-09 07:27:21 +08:00
|
|
|
bool ca_data_set;
|
2018-04-13 03:28:52 +08:00
|
|
|
bool cert_data_set;
|
|
|
|
bool key_data_set;
|
|
|
|
bool verify_peers_set;
|
|
|
|
|
2018-05-09 07:27:21 +08:00
|
|
|
struct stack_st_X509* roots;
|
2018-04-13 03:28:52 +08:00
|
|
|
|
2018-05-09 07:27:21 +08:00
|
|
|
std::vector<Reference<FDBLibTLSVerify>> verify_rules;
|
2018-04-13 03:28:52 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* FDB_LIBTLS_POLICY_H */
|