Qore Programming Language  0.8.11.1
QoreSSLCertificate.h
1 /* -*- mode: c++; indent-tabs-mode: nil -*- */
2 /*
3  QoreSSLCertificate.h
4 
5  Qore Programming Language
6 
7  Copyright (C) 2003 - 2014 David Nichols
8 
9  Permission is hereby granted, free of charge, to any person obtaining a
10  copy of this software and associated documentation files (the "Software"),
11  to deal in the Software without restriction, including without limitation
12  the rights to use, copy, modify, merge, publish, distribute, sublicense,
13  and/or sell copies of the Software, and to permit persons to whom the
14  Software is furnished to do so, subject to the following conditions:
15 
16  The above copyright notice and this permission notice shall be included in
17  all copies or substantial portions of the Software.
18 
19  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25  DEALINGS IN THE SOFTWARE.
26 
27  Note that the Qore library is released under a choice of three open-source
28  licenses: MIT (as above), LGPL 2+, or GPL 2+; see README-LICENSE for more
29  information.
30 */
31 
32 #ifndef _QORE_QORESSLCERTIFICATE_H
33 
34 #define _QORE_QORESSLCERTIFICATE_H
35 
36 #include <qore/QoreSSLBase.h>
37 
38 #include <openssl/ssl.h>
39 #include <openssl/pem.h>
40 
43  private:
45  struct qore_sslcert_private *priv;
46 
47  DLLLOCAL AbstractQoreNode *doPurposeValue(int id, int ca) const;
48 
50  DLLLOCAL QoreSSLCertificate(const QoreSSLCertificate&);
51 
53  DLLLOCAL QoreSSLCertificate& operator=(const QoreSSLCertificate&);
54 
55  protected:
57  DLLLOCAL virtual ~QoreSSLCertificate();
58 
59  public:
61 
63  DLLEXPORT QoreSSLCertificate(X509 *c);
64 
66 
69  DLLEXPORT QoreSSLCertificate(const BinaryNode *bin, ExceptionSink *xsink);
70 
72 
75  DLLEXPORT QoreSSLCertificate(const QoreString *str, ExceptionSink *xsink);
76 
78 
81  DLLLOCAL QoreSSLCertificate(const char *fn, ExceptionSink *xsink);
82 
84  DLLEXPORT operator bool() const;
85 
87 
89  DLLEXPORT QoreStringNode *getPEM(ExceptionSink *xsink) const;
90 
91  // caller does NOT own the X509 pointer returned; "const" cannot be used because of the openssl API does not support it
92  DLLEXPORT X509 *getData() const;
93 
94  // caller owns value returned
95  DLLEXPORT QoreHashNode *getSubjectHash() const;
96 
97  // caller owns value returned
98  DLLEXPORT QoreHashNode *getIssuerHash() const;
99  DLLEXPORT int64 getSerialNumber() const;
100  DLLEXPORT int64 getVersion() const;
101 
102  // caller owns value returned
103  DLLEXPORT QoreHashNode *getPurposeHash() const;
104 
105  // caller owns value returned
106  DLLEXPORT DateTimeNode *getNotBeforeDate() const;
107 
108  // caller owns value returned
109  DLLEXPORT DateTimeNode *getNotAfterDate() const;
110 
111  // caller owns value returned
112  DLLEXPORT QoreStringNode *getSignatureType() const;
113 
114  // caller owns value returned
115  DLLEXPORT BinaryNode *getSignature() const;
116 
117  // caller owns value returned
118  DLLEXPORT QoreStringNode *getPublicKeyAlgorithm() const;
119 
120  // caller owns value returned
121  DLLEXPORT BinaryNode *getPublicKey() const;
122 
123  // caller owns value returned
124  DLLEXPORT QoreHashNode *getInfo() const;
125 };
126 
127 #endif
DLLEXPORT QoreStringNode * getPEM(ExceptionSink *xsink) const
returns a string in PEM format representing the certificate; caller owns the QoreStringNode reference...
represents an X509 certificate, reference-counted, dynamically-allocated only
Definition: QoreSSLCertificate.h:42
This is the hash or associative list container type in Qore, dynamically allocated only...
Definition: QoreHashNode.h:49
the base class for all data to be used as private data of Qore objects
Definition: AbstractPrivateData.h:44
The base class for all value and parse types in Qore expression trees.
Definition: AbstractQoreNode.h:55
virtual DLLLOCAL ~QoreSSLCertificate()
the destructor is protected to ensure that it's only dynamically allocated (use deref() to delete) ...
Qore's string type supported by the QoreEncoding class.
Definition: QoreString.h:50
Qore's string value type, reference counted, dynamically-allocated only.
Definition: QoreStringNode.h:48
Qore's parse tree/value type for date-time values, reference-counted, dynamically-allocated only...
Definition: DateTimeNode.h:44
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:43
offers static functions to help with translating openssl data structures to Qore data structures ...
Definition: QoreSSLBase.h:40
holds arbitrary binary data
Definition: BinaryNode.h:41