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