]> WPIA git - cassiopeia.git/blob - src/main.cpp
e0a6c10190276444bde61cfadb35e2766dd123d1
[cassiopeia.git] / src / main.cpp
1 /*
2     Cassiopeia - CAcert signing module
3     Copyright (C) 2014  CAcert Inc.
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License along
16     with this program; if not, write to the Free Software Foundation, Inc.,
17     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 #include <iostream>
20
21 #include "database.h"
22 #include "mysql.h"
23
24 int main( int argc, const char* argv[] ) {
25     if( argc < 2 ) {
26         std::cout << argv[0] << " password" << std::endl;
27         return 1;
28     }
29
30     std::shared_ptr<JobProvider> jp( new MySQLJobProvider( "localhost", "cacert", argv[1], "cacert" ) );
31     std::shared_ptr<Job> job = jp->fetchJob();
32
33     if( !job ) {
34         std::cout << "Nothing to work on" << std::endl;
35         return 2;
36     }
37
38     if( job->task == "sign" ) {
39         std::cout << "signing" << std::endl;
40         std::shared_ptr<TBSCertificate> cert = jp->fetchTBSCert( job );
41         std::cout << cert->CN << std::endl;
42         std::cout << cert->md << std::endl;
43         std::cout << cert->csr << std::endl;
44         std::cout << cert->csr_type << std::endl;
45     }
46
47     if( !jp->finishJob( job ) ) {
48         return 1;
49     }
50
51     return 0;
52 }