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
22
23/*
24 * NOTE: All functions in this section are thread-safe because objects of C4Cert are immutable.
25 */
26
29
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
86CBL_CORE_API bool c4cert_isSignedBy(C4Cert* cert, C4Cert* issuer) C4API;
87
90NODISCARD CBL_CORE_API C4KeyPair* c4cert_getPublicKey(C4Cert*) C4API;
91
95NODISCARD CBL_CORE_API C4KeyPair* c4cert_loadPersistentPrivateKey(C4Cert*, C4Error* C4NULLABLE outError) C4API;
96
98
99
102
112NODISCARD CBL_CORE_API C4Cert* c4cert_createRequest(const C4CertNameComponent* nameComponents, size_t nameCount,
113 C4CertUsage certUsages, C4KeyPair* subjectKey,
114 C4Error* C4NULLABLE outError) C4API;
115
118NODISCARD CBL_CORE_API C4Cert* c4cert_requestFromData(C4Slice certRequestData, C4Error* C4NULLABLE outError) C4API;
119
121CBL_CORE_API bool c4cert_isSigned(C4Cert*) C4API;
122
127typedef void (*C4CertSigningCallback)(void* context, C4Cert* signedCert, C4Error error);
128
143NODISCARD CBL_CORE_API bool c4cert_sendSigningRequest(C4Cert* certRequest, C4Address address, C4Slice optionsDictFleece,
144 C4CertSigningCallback callback, void* C4NULLABLE context,
145 C4Error* C4NULLABLE outError) C4API;
146
159NODISCARD CBL_CORE_API C4Cert* c4cert_signRequest(C4Cert* certRequest, const C4CertIssuerParameters* C4NULLABLE params,
160 C4KeyPair* issuerPrivateKey, C4Cert* C4NULLABLE issuerCert,
161 C4Error* C4NULLABLE outError) C4API;
162
164
165
168
171NODISCARD CBL_CORE_API C4Cert* C4NULLABLE c4cert_nextInChain(C4Cert*) C4API;
172
175CBL_CORE_API C4SliceResult c4cert_copyChainData(C4Cert*) C4API;
176
178
179
182
190NODISCARD CBL_CORE_API bool c4cert_save(C4Cert* C4NULLABLE cert, bool entireChain, C4String name,
191 C4Error* C4NULLABLE outError);
192
198NODISCARD CBL_CORE_API C4Cert* c4cert_load(C4String name, C4Error* C4NULLABLE outError);
199
205NODISCARD CBL_CORE_API bool c4cert_exists(C4String name, C4Error* C4NULLABLE outError);
206
208
209
212
225NODISCARD CBL_CORE_API C4KeyPair* c4keypair_generate(C4KeyPairAlgorithm algorithm, unsigned sizeInBits, bool persistent,
226 C4Error* C4NULLABLE outError) C4API;
227
231NODISCARD CBL_CORE_API C4KeyPair* c4keypair_fromPublicKeyData(C4Slice publicKeyData,
232 C4Error* C4NULLABLE outError) C4API;
233
237NODISCARD CBL_CORE_API C4KeyPair* c4keypair_fromPrivateKeyData(C4Slice privateKeyData, C4Slice passwordOrNull,
238 C4Error* C4NULLABLE outError) C4API;
239
241CBL_CORE_API bool c4keypair_hasPrivateKey(C4KeyPair*) C4API;
242
245CBL_CORE_API C4SliceResult c4keypair_publicKeyDigest(C4KeyPair*) C4API;
246
249CBL_CORE_API C4SliceResult c4keypair_publicKeyData(C4KeyPair*) C4API;
250
254CBL_CORE_API C4SliceResult c4keypair_privateKeyData(C4KeyPair*) C4API;
255
257CBL_CORE_API bool c4keypair_isPersistent(C4KeyPair*) C4API;
258
262NODISCARD CBL_CORE_API C4KeyPair* c4keypair_persistentWithPublicKey(C4KeyPair*, C4Error* C4NULLABLE outError) C4API;
263
265NODISCARD CBL_CORE_API bool c4keypair_removePersistent(C4KeyPair*, C4Error* C4NULLABLE outError) C4API;
266
268
269
272
282NODISCARD CBL_CORE_API C4KeyPair* c4keypair_fromExternal(C4KeyPairAlgorithm algorithm, size_t keySizeInBits,
283 void* externalKey, C4ExternalKeyCallbacks callbacks,
284 C4Error* C4NULLABLE outError);
285
287
289
290#endif // COUCHBASE_ENTERPRISE
291
#define NODISCARD
Definition CompilerSupport.h:63
#define CBL_CORE_API
Definition c4Compat.h:131
#define C4NULLABLE
Definition c4Compat.h:38
#define C4API
Definition c4Compat.h:106
#define C4_ASSUME_NONNULL_BEGIN
Definition c4Compat.h:36
#define C4API_END_DECLS
Definition c4Compat.h:108
#define C4API_BEGIN_DECLS
Definition c4Compat.h:107
#define C4_ASSUME_NONNULL_END
Definition c4Compat.h:37
C4Slice C4String
Definition c4Base.h:51
int64_t C4Timestamp
A date/time representation used for document expiration (and in date/time queries....
Definition c4Base.h:95
FLSliceResult C4SliceResult
Definition c4Base.h:50
C4SliceResult C4StringResult
Definition c4Base.h:53
struct C4KeyPair C4KeyPair
An asymmetric key or key-pair (RSA, etc.) The private key may or may not be present.
Definition c4Base.h:153
FLSlice C4Slice
Definition c4Base.h:48
struct C4Cert C4Cert
An X.509 certificate, or certificate signing request (CSR).
Definition c4Base.h:122
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:57
An error value.
Definition c4Error.h:133