1 /* vi: set sw=4 ts=4: 2 * 3 * Copyright (C) 2001 - 2020 Christian Hohnstaedt. 4 * 5 * All rights reserved. 6 */ 7 8 #ifndef __PKI_X509REQ_H 9 #define __PKI_X509REQ_H 10 11 #include <openssl/x509.h> 12 #include <openssl/pem.h> 13 #include "pki_key.h" 14 #include "pki_x509super.h" 15 #include "x509v3ext.h" 16 #include "x509name.h" 17 18 #define VIEW_x509req_request 7 19 #define VIEW_x509req_signed 8 20 21 class pki_x509; 22 23 class pki_x509req : public pki_x509super 24 { 25 Q_OBJECT 26 27 mutable int x509count; 28 protected: 29 X509_REQ *request; 30 bool done; 31 int sigAlg() const; 32 void collect_properties(QMap<QString, QString> &prp) const; 33 34 public: 35 pki_x509req(const QString &name = QString()); 36 pki_x509req(const pki_x509req *req); 37 ~pki_x509req(); 38 39 extList getV3ext() const; 40 void fromPEM_BIO(BIO *bio, const QString &name); 41 void fload(const QString &fname); 42 void writeDefault(const QString &dirname) const; 43 void fromData(const unsigned char *p, db_header_t *head); 44 x509name getSubject() const; 45 void writeReq(XFile &file, bool pem) const; 46 void markSigned(bool signe); 47 void print(BioByteArray &b, enum print_opt opt) const; getReq()48 X509_REQ *getReq() 49 { 50 return request; 51 } 52 void addAttribute(int nid, QString content); 53 QString getAttribute(int nid) const; 54 int issuedCerts() const; 55 56 bool verify() const; 57 pki_key *getPubKey() const; 58 void createReq(pki_key *key, const x509name &dn, 59 const EVP_MD *md, extList el); 60 void setSubject(const x509name &n); 61 QVariant column_data(const dbheader *hd) const; 62 QVariant getIcon(const dbheader *hd) const; 63 void setDone(bool d = true) 64 { 65 done = d; 66 } getDone()67 bool getDone() const 68 { 69 return done; 70 } resetX509count()71 void resetX509count() const 72 { 73 x509count = -1; 74 } 75 virtual QString getMsg(msg_type msg) const; 76 void d2i(QByteArray &ba); 77 QByteArray i2d() const; 78 bool pem(BioByteArray &, int); 79 bool visible() const; 80 QSqlError insertSqlData(); 81 QSqlError deleteSqlData(); 82 void restoreSql(const QSqlRecord &rec); 83 }; 84 85 Q_DECLARE_METATYPE(pki_x509req *); 86 #endif 87