]>
sourceware.org Git - systemtap.git/blob - stap-authorize-cert.cxx
2 Add the certificate contained in the given file to the given certificate database.
4 Copyright (C) 2011 Red Hat Inc.
6 This file is part of systemtap, and is free software. You can
7 redistribute it and/or modify it under the terms of the GNU General Public
8 License as published by the Free Software Foundation; either version 2 of the
9 License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
27 #include "nsscommon.h"
31 // Called by methods within nsscommon.
34 nsscommon_error (const char *msg
, int logit
__attribute ((unused
)))
36 clog
<< msg
<< endl
<< flush
;
40 fatal (const char *msg
)
42 nsscommon_error (msg
);
47 main (int argc
, char **argv
) {
48 // Obtain the filename of the certificate.
51 fatal (_("Certificate file must be specified"));
54 const char *certFileName
= argv
[1];
56 // Obtain the certificate database directory name.
59 fatal (_("Certificate database directory must be specified"));
62 const char *certDBName
= argv
[2];
64 // Make sure NSPR is initialized. Must be done before NSS is initialized
65 PR_Init (PR_SYSTEM_THREAD
, PR_PRIORITY_NORMAL
, 1);
66 /* Set the cert database password callback. */
67 PK11_SetPasswordFunc (nssPasswordCallback
);
69 // Add the certificate to the database.
70 SECStatus secStatus
= add_client_cert (certFileName
, certDBName
);
71 if (secStatus
!= SECSuccess
)
73 // NSS message already issued.
74 nsscommon_error (_("Unable to authorize certificate"));
80 return secStatus
== SECSuccess
;
This page took 0.037846 seconds and 5 git commands to generate.