| 1 |
#ifndef AWS_IO_PKI_UTILS_H |
| 2 |
#define AWS_IO_PKI_UTILS_H |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
#include <aws/io/io.h> |
| 8 |
|
| 9 |
#ifdef _WIN32 |
| 10 |
|
| 11 |
|
| 12 |
# define NOMINMAX |
| 13 |
# define NOCRYPT |
| 14 |
# include <windows.h> |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
# include <wincrypt.h> |
| 22 |
#endif |
| 23 |
|
| 24 |
#ifdef AWS_OS_APPLE |
| 25 |
|
| 26 |
# include <CoreFoundation/CFArray.h> |
| 27 |
# include <Security/Security.h> |
| 28 |
#endif |
| 29 |
|
| 30 |
struct aws_secitem_options; |
| 31 |
struct aws_string; |
| 32 |
|
| 33 |
AWS_EXTERN_C_BEGIN |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
AWS_IO_API const char *aws_determine_default_pki_dir(void); |
| 40 |
AWS_IO_API const char *aws_determine_default_pki_ca_file(void); |
| 41 |
|
| 42 |
#ifdef AWS_OS_APPLE |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
int aws_import_public_and_private_keys_to_identity( |
| 48 |
struct aws_allocator *alloc, |
| 49 |
CFAllocatorRef cf_alloc, |
| 50 |
const struct aws_byte_cursor *public_cert_chain, |
| 51 |
const struct aws_byte_cursor *private_key, |
| 52 |
CFArrayRef *identity, |
| 53 |
const struct aws_string *keychain_path); |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
int aws_import_pkcs12_to_identity( |
| 60 |
CFAllocatorRef cf_alloc, |
| 61 |
const struct aws_byte_cursor *pkcs12_cursor, |
| 62 |
const struct aws_byte_cursor *password, |
| 63 |
CFArrayRef *identity); |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
int aws_import_trusted_certificates( |
| 70 |
struct aws_allocator *alloc, |
| 71 |
CFAllocatorRef cf_alloc, |
| 72 |
const struct aws_byte_cursor *certificates_blob, |
| 73 |
CFArrayRef *certs); |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
int aws_secitem_import_cert_and_key( |
| 81 |
struct aws_allocator *alloc, |
| 82 |
CFAllocatorRef cf_alloc, |
| 83 |
const struct aws_byte_cursor *public_cert_chain, |
| 84 |
const struct aws_byte_cursor *private_key, |
| 85 |
sec_identity_t *secitem_identity, |
| 86 |
const struct aws_secitem_options *secitem_options); |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
int aws_secitem_import_pkcs12( |
| 94 |
CFAllocatorRef cf_alloc, |
| 95 |
const struct aws_byte_cursor *pkcs12_cursor, |
| 96 |
const struct aws_byte_cursor *password, |
| 97 |
sec_identity_t *out_identity); |
| 98 |
|
| 99 |
#endif |
| 100 |
|
| 101 |
#ifdef _WIN32 |
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
AWS_IO_API int aws_load_cert_from_system_cert_store( |
| 109 |
const char *cert_path, |
| 110 |
HCERTSTORE *cert_store, |
| 111 |
PCCERT_CONTEXT *certs); |
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
AWS_IO_API int aws_import_trusted_certificates( |
| 118 |
struct aws_allocator *alloc, |
| 119 |
const struct aws_byte_cursor *certificates_blob, |
| 120 |
HCERTSTORE *cert_store); |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
AWS_IO_API void aws_close_cert_store(HCERTSTORE cert_store); |
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
AWS_IO_API int aws_import_key_pair_to_cert_context( |
| 132 |
struct aws_allocator *alloc, |
| 133 |
const struct aws_byte_cursor *public_cert_chain, |
| 134 |
const struct aws_byte_cursor *private_key, |
| 135 |
bool is_client_mode, |
| 136 |
HCERTSTORE *cert_store, |
| 137 |
PCCERT_CONTEXT *certs, |
| 138 |
HCRYPTPROV *crypto_provider, |
| 139 |
HCRYPTKEY *private_key_handle, |
| 140 |
bool *tls13_disabled); |
| 141 |
|
| 142 |
#endif |
| 143 |
|
| 144 |
AWS_EXTERN_C_END |
| 145 |
|
| 146 |
#endif |