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