Add missing commas in pod files
[openssl.git] / doc / man3 / PKCS12_newpass.pod
1 =pod
2
3 =head1 NAME
4
5 PKCS12_newpass - change the password of a PKCS12 structure
6
7 =head1 SYNOPSIS
8
9  #include <openssl/pkcs12.h>
10
11  int PKCS12_newpass(PKCS12 *p12, const char *oldpass, const char *newpass);
12
13 =head1 DESCRIPTION
14
15 PKCS12_newpass() changes the password of a PKCS12 structure.
16
17 B<p12> is a pointer to a PKCS12 structure. B<oldpass> is the existing password
18 and B<newpass> is the new password.
19
20 =head1 NOTES
21
22 Each of B<oldpass> and B<newpass> is independently interpreted as a string in
23 the UTF-8 encoding. If it is not valid UTF-8, it is assumed to be ISO8859-1
24 instead.
25
26 In particular, this means that passwords in the locale character set
27 (or code page on Windows) must potentially be converted to UTF-8 before
28 use. This may include passwords from local text files, or input from
29 the terminal or command line. Refer to the documentation of
30 L<UI_OpenSSL(3)>, for example.
31
32 =head1 RETURN VALUES
33
34 PKCS12_newpass() returns 1 on success or 0 on failure. Applications can
35 retrieve the most recent error from PKCS12_newpass() with ERR_get_error().
36
37 =head1 EXAMPLE
38
39 This example loads a PKCS#12 file, changes its password and writes out
40 the result to a new file.
41
42  #include <stdio.h>
43  #include <stdlib.h>
44  #include <openssl/pem.h>
45  #include <openssl/err.h>
46  #include <openssl/pkcs12.h>
47
48  int main(int argc, char **argv)
49  {
50     FILE *fp;
51     PKCS12 *p12;
52     if (argc != 5) {
53         fprintf(stderr, "Usage: pkread p12file password newpass opfile\n");
54         return 1;
55     }
56     if ((fp = fopen(argv[1], "rb")) == NULL) {
57         fprintf(stderr, "Error opening file %s\n", argv[1]);
58         return 1;
59     }
60     p12 = d2i_PKCS12_fp(fp, NULL);
61     fclose(fp);
62     if (p12 == NULL) {
63         fprintf(stderr, "Error reading PKCS#12 file\n");
64         ERR_print_errors_fp(stderr);
65         return 1;
66     }
67     if (PKCS12_newpass(p12, argv[2], argv[3]) == 0) {
68         fprintf(stderr, "Error changing password\n");
69         ERR_print_errors_fp(stderr);
70         PKCS12_free(p12);
71         return 1;
72     }
73     if ((fp = fopen(argv[4], "wb")) == NULL) {
74         fprintf(stderr, "Error opening file %s\n", argv[4]);
75         PKCS12_free(p12);
76         return 1;
77     }
78     i2d_PKCS12_fp(fp, p12);
79     PKCS12_free(p12);
80     fclose(fp);
81     return 0;
82  }
83
84
85 =head1 NOTES
86
87 If the PKCS#12 structure does not have a password, then you must use the empty
88 string "" for B<oldpass>. Using NULL for B<oldpass> will result in a
89 PKCS12_newpass() failure.
90
91 If the wrong password is used for B<oldpass> then the function will fail,
92 with a MAC verification error. In rare cases the PKCS12 structure does not
93 contain a MAC: in this case it will usually fail with a decryption padding
94 error.
95
96 =head1 BUGS
97
98 The password format is a NULL terminated ASCII string which is converted to
99 Unicode form internally. As a result some passwords cannot be supplied to
100 this function.
101
102 =head1 SEE ALSO
103
104 L<PKCS12_create(3)>, L<ERR_get_error(3)>
105
106 =head1 COPYRIGHT
107
108 Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
109
110 Licensed under the OpenSSL license (the "License").  You may not use
111 this file except in compliance with the License.  You can obtain a copy
112 in the file LICENSE in the source distribution or at
113 L<https://www.openssl.org/source/license.html>.
114
115 =cut