foundationdb/FDBLibTLS/FDBLibTLSPolicy.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

76 lines
2.4 KiB
C
Raw Normal View History

2018-04-20 01:11:55 +08:00
/*
* FDBLibTLSPolicy.h
*
* This source file is part of the FoundationDB open source project
*
2022-03-22 04:36:23 +08:00
* Copyright 2013-2022 Apple Inc. and the FoundationDB project authors
2018-04-20 01:11:55 +08:00
*
* 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.
*/
#ifndef FDB_LIBTLS_POLICY_H
#define FDB_LIBTLS_POLICY_H
#pragma once
#include "fdbrpc/ITLSPlugin.h"
#include "flow/FastRef.h"
#include "FDBLibTLS/FDBLibTLSPlugin.h"
#include "FDBLibTLS/FDBLibTLSVerify.h"
2018-05-09 07:27:21 +08:00
#include <string>
2018-05-09 07:27:21 +08:00
#include <vector>
struct FDBLibTLSPolicy : ITLSPolicy, ReferenceCounted<FDBLibTLSPolicy> {
FDBLibTLSPolicy(Reference<FDBLibTLSPlugin> plugin);
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-05-09 07:27:21 +08:00
struct stack_st_X509* parse_cert_pem(const uint8_t* cert_pem, size_t cert_pem_len);
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);
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-05-09 07:27:21 +08:00
struct tls_config* tls_cfg;
bool session_created;
2018-05-09 07:27:21 +08:00
bool ca_data_set;
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-05-09 07:27:21 +08:00
std::vector<Reference<FDBLibTLSVerify>> verify_rules;
};
#endif /* FDB_LIBTLS_POLICY_H */