LiteCore
Couchbase Lite cross-platform core implementation
Loading...
Searching...
No Matches
c4Certificate.h
Go to the documentation of this file.
1//
2// c4Certificate.h
3//
4// Copyright 2019-Present Couchbase, Inc.
5//
6// Use of this software is governed by the Business Source License included
7// in the file licenses/BSL-Couchbase.txt. As of the Change Date specified
8// in that file, in accordance with the Business Source License, use of this
9// software will be governed by the Apache License, Version 2.0, included in
10// the file licenses/APL2.txt.
11//
12
13#pragma once
14
15#include "c4CertificateTypes.h"
16
19
23/*
24 * NOTE: All functions in this section are thread-safe because objects of C4Cert are immutable.
25 */
26
35 C4Timestamp* C4NULLABLE outExpires);
36
37#ifdef COUCHBASE_ENTERPRISE
38
44NODISCARD CBL_CORE_API C4Cert* c4cert_fromData(C4Slice certData, C4Error* C4NULLABLE outError) C4API;
45
50CBL_CORE_API C4SliceResult c4cert_copyData(C4Cert*, bool pemEncoded) C4API;
51
55
61CBL_CORE_API C4StringResult c4cert_subjectName(C4Cert*) C4API;
62
66CBL_CORE_API C4StringResult c4cert_subjectNameComponent(C4Cert*, C4CertNameAttributeID) C4API;
67
75NODISCARD CBL_CORE_API bool c4cert_subjectNameAtIndex(C4Cert* cert, unsigned index, C4CertNameInfo* outInfo) C4API;
76
77
79CBL_CORE_API C4CertUsage c4cert_usages(C4Cert*) C4API;
80
83CBL_CORE_API bool c4cert_isSelfSigned(C4Cert*) C4API;
84
87NODISCARD CBL_CORE_API C4KeyPair* c4cert_getPublicKey(C4Cert*) C4API;
88
92NODISCARD CBL_CORE_API C4KeyPair* c4cert_loadPersistentPrivateKey(C4Cert*, C4Error* C4NULLABLE outError) C4API;
93
109NODISCARD CBL_CORE_API C4Cert* c4cert_createRequest(const C4CertNameComponent* nameComponents, size_t nameCount,
110 C4CertUsage certUsages, C4KeyPair* subjectKey,
111 C4Error* C4NULLABLE outError) C4API;
112
115NODISCARD CBL_CORE_API C4Cert* c4cert_requestFromData(C4Slice certRequestData, C4Error* C4NULLABLE outError) C4API;
116
118CBL_CORE_API bool c4cert_isSigned(C4Cert*) C4API;
119
124typedef void (*C4CertSigningCallback)(void* context, C4Cert* signedCert, C4Error error);
125
140NODISCARD CBL_CORE_API bool c4cert_sendSigningRequest(C4Cert* certRequest, C4Address address, C4Slice optionsDictFleece,
141 C4CertSigningCallback callback, void* C4NULLABLE context,
142 C4Error* C4NULLABLE outError) C4API;
143
156NODISCARD CBL_CORE_API C4Cert* c4cert_signRequest(C4Cert* certRequest, const C4CertIssuerParameters* C4NULLABLE params,
157 C4KeyPair* issuerPrivateKey, C4Cert* C4NULLABLE issuerCert,
158 C4Error* C4NULLABLE outError) C4API;
159
168NODISCARD CBL_CORE_API C4Cert* C4NULLABLE c4cert_nextInChain(C4Cert*) C4API;
169
172CBL_CORE_API C4SliceResult c4cert_copyChainData(C4Cert*) C4API;
173
187NODISCARD CBL_CORE_API bool c4cert_save(C4Cert* C4NULLABLE cert, bool entireChain, C4String name,
188 C4Error* C4NULLABLE outError);
189
195NODISCARD CBL_CORE_API C4Cert* c4cert_load(C4String name, C4Error* C4NULLABLE outError);
196
202NODISCARD CBL_CORE_API bool c4cert_exists(C4String name, C4Error* C4NULLABLE outError);
203
222NODISCARD CBL_CORE_API C4KeyPair* c4keypair_generate(C4KeyPairAlgorithm algorithm, unsigned sizeInBits, bool persistent,
223 C4Error* C4NULLABLE outError) C4API;
224
228NODISCARD CBL_CORE_API C4KeyPair* c4keypair_fromPublicKeyData(C4Slice publicKeyData,
229 C4Error* C4NULLABLE outError) C4API;
230
234NODISCARD CBL_CORE_API C4KeyPair* c4keypair_fromPrivateKeyData(C4Slice privateKeyData, C4Slice passwordOrNull,
235 C4Error* C4NULLABLE outError) C4API;
236
238CBL_CORE_API bool c4keypair_hasPrivateKey(C4KeyPair*) C4API;
239
242CBL_CORE_API C4SliceResult c4keypair_publicKeyDigest(C4KeyPair*) C4API;
243
246CBL_CORE_API C4SliceResult c4keypair_publicKeyData(C4KeyPair*) C4API;
247
251CBL_CORE_API C4SliceResult c4keypair_privateKeyData(C4KeyPair*) C4API;
252
254CBL_CORE_API bool c4keypair_isPersistent(C4KeyPair*) C4API;
255
259NODISCARD CBL_CORE_API C4KeyPair* c4keypair_persistentWithPublicKey(C4KeyPair*, C4Error* C4NULLABLE outError) C4API;
260
262NODISCARD CBL_CORE_API bool c4keypair_removePersistent(C4KeyPair*, C4Error* C4NULLABLE outError) C4API;
263
279NODISCARD CBL_CORE_API C4KeyPair* c4keypair_fromExternal(C4KeyPairAlgorithm algorithm, size_t keySizeInBits,
280 void* externalKey, C4ExternalKeyCallbacks callbacks,
281 C4Error* C4NULLABLE outError);
282
287#endif // COUCHBASE_ENTERPRISE
288
#define NODISCARD
Definition CompilerSupport.h:59
#define CBL_CORE_API
Definition c4Compat.h:134
#define C4NULLABLE
Definition c4Compat.h:38
#define C4API
Definition c4Compat.h:114
#define C4_ASSUME_NONNULL_BEGIN
Definition c4Compat.h:36
#define C4API_END_DECLS
Definition c4Compat.h:116
#define C4API_BEGIN_DECLS
Definition c4Compat.h:115
#define C4_ASSUME_NONNULL_END
Definition c4Compat.h:37
int64_t C4Timestamp
A date/time representation used for document expiration (and in date/time queries....
Definition c4Base.h:96
struct C4KeyPair C4KeyPair
An asymmetric key or key-pair (RSA, etc.) The private key may or may not be present.
Definition c4Base.h:154
struct C4Cert C4Cert
An X.509 certificate, or certificate signing request (CSR).
Definition c4Base.h:123
CBL_CORE_API void c4cert_getValidTimespan(C4Cert *cert, C4Timestamp *outCreated, C4Timestamp *outExpires)
Returns the time range during which a (signed) certificate is valid.
A simple parsed-URL type.
Definition c4ReplicatorTypes.h:56
An error value.
Definition c4Error.h:133
A simple reference to a block of memory.
Definition FLSlice.h:45
A heap-allocated block of memory returned from an API call.
Definition FLSlice.h:63