xref: /freebsd/crypto/openssl/doc/man7/ossl_store.pod (revision a7148ab39c03abd4d1a84997c70bf96f15dd2a09)
1e71b7053SJung-uk Kim=pod
2e71b7053SJung-uk Kim
3e71b7053SJung-uk Kim=head1 NAME
4e71b7053SJung-uk Kim
5e71b7053SJung-uk Kimossl_store - Store retrieval functions
6e71b7053SJung-uk Kim
7e71b7053SJung-uk Kim=head1 SYNOPSIS
8e71b7053SJung-uk Kim
9b077aed3SPierre Pronchery=for openssl generic
10e71b7053SJung-uk Kim
11e71b7053SJung-uk Kim#include <openssl/store.h>
12e71b7053SJung-uk Kim
13e71b7053SJung-uk Kim=head1 DESCRIPTION
14e71b7053SJung-uk Kim
15e71b7053SJung-uk Kim=head2 General
16e71b7053SJung-uk Kim
17e71b7053SJung-uk KimA STORE is a layer of functionality to retrieve a number of supported
18e71b7053SJung-uk Kimobjects from a repository of any kind, addressable as a filename or
19e71b7053SJung-uk Kimas a URI.
20e71b7053SJung-uk Kim
21e71b7053SJung-uk KimThe functionality supports the pattern "open a channel to the
22e71b7053SJung-uk Kimrepository", "loop and retrieve one object at a time", and "finish up
23e71b7053SJung-uk Kimby closing the channel".
24e71b7053SJung-uk Kim
25e71b7053SJung-uk KimThe retrieved objects are returned as a wrapper type B<OSSL_STORE_INFO>,
26e71b7053SJung-uk Kimfrom which an OpenSSL type can be retrieved.
27e71b7053SJung-uk Kim
28e71b7053SJung-uk Kim=head2 URI schemes and loaders
29e71b7053SJung-uk Kim
30e71b7053SJung-uk KimSupport for a URI scheme is called a STORE "loader", and can be added
31e71b7053SJung-uk Kimdynamically from the calling application or from a loadable engine.
32e71b7053SJung-uk Kim
33e71b7053SJung-uk KimSupport for the 'file' scheme is built into C<libcrypto>.
34e71b7053SJung-uk KimSee L<ossl_store-file(7)> for more information.
35e71b7053SJung-uk Kim
36e71b7053SJung-uk Kim=head2 UI_METHOD and pass phrases
37e71b7053SJung-uk Kim
38e71b7053SJung-uk KimThe B<OSS_STORE> API does nothing to enforce any specific format or
39e71b7053SJung-uk Kimencoding on the pass phrase that the B<UI_METHOD> provides.  However,
40e71b7053SJung-uk Kimthe pass phrase is expected to be UTF-8 encoded.  The result of any
41e71b7053SJung-uk Kimother encoding is undefined.
42e71b7053SJung-uk Kim
43e71b7053SJung-uk Kim=head1 EXAMPLES
44e71b7053SJung-uk Kim
45e71b7053SJung-uk Kim=head2 A generic call
46e71b7053SJung-uk Kim
47*a7148ab3SEnji Cooper #include <openssl/ui.h> /* for UI_get_default_method */
48*a7148ab3SEnji Cooper #include <openssl/store.h>
49*a7148ab3SEnji Cooper
50*a7148ab3SEnji Cooper OSSL_STORE_CTX *ctx = OSSL_STORE_open("file:/foo/bar/data.pem",
51*a7148ab3SEnji Cooper                        UI_get_default_method(), NULL, NULL, NULL);
52e71b7053SJung-uk Kim
53e71b7053SJung-uk Kim /*
54e71b7053SJung-uk Kim  * OSSL_STORE_eof() simulates file semantics for any repository to signal
55e71b7053SJung-uk Kim  * that no more data can be expected
56e71b7053SJung-uk Kim  */
57e71b7053SJung-uk Kim while (!OSSL_STORE_eof(ctx)) {
58e71b7053SJung-uk Kim     OSSL_STORE_INFO *info = OSSL_STORE_load(ctx);
59e71b7053SJung-uk Kim
60e71b7053SJung-uk Kim     /*
61e71b7053SJung-uk Kim      * Do whatever is necessary with the OSSL_STORE_INFO,
62e71b7053SJung-uk Kim      * here just one example
63e71b7053SJung-uk Kim      */
64e71b7053SJung-uk Kim     switch (OSSL_STORE_INFO_get_type(info)) {
65b2bf0c7eSJung-uk Kim     case OSSL_STORE_INFO_CERT:
66e71b7053SJung-uk Kim         /* Print the X.509 certificate text */
67e71b7053SJung-uk Kim         X509_print_fp(stdout, OSSL_STORE_INFO_get0_CERT(info));
68e71b7053SJung-uk Kim         /* Print the X.509 certificate PEM output */
69e71b7053SJung-uk Kim         PEM_write_X509(stdout, OSSL_STORE_INFO_get0_CERT(info));
70e71b7053SJung-uk Kim         break;
71e71b7053SJung-uk Kim     }
72*a7148ab3SEnji Cooper     OSSL_STORE_INFO_free(info);
73e71b7053SJung-uk Kim }
74e71b7053SJung-uk Kim
75e71b7053SJung-uk Kim OSSL_STORE_close(ctx);
76e71b7053SJung-uk Kim
77e71b7053SJung-uk Kim=head1 SEE ALSO
78e71b7053SJung-uk Kim
79e71b7053SJung-uk KimL<OSSL_STORE_INFO(3)>, L<OSSL_STORE_LOADER(3)>,
80e71b7053SJung-uk KimL<OSSL_STORE_open(3)>, L<OSSL_STORE_expect(3)>,
81e71b7053SJung-uk KimL<OSSL_STORE_SEARCH(3)>
82e71b7053SJung-uk Kim
83e71b7053SJung-uk Kim=head1 COPYRIGHT
84e71b7053SJung-uk Kim
85*a7148ab3SEnji CooperCopyright 2016-2024 The OpenSSL Project Authors. All Rights Reserved.
86e71b7053SJung-uk Kim
87b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License").  You may not use
88e71b7053SJung-uk Kimthis file except in compliance with the License.  You can obtain a copy
89e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at
90e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>.
91e71b7053SJung-uk Kim
92e71b7053SJung-uk Kim=cut
93