Qore Programming Language  1.12.0
QoreSSLCertificate.h
1 /* -*- mode: c++; indent-tabs-mode: nil -*- */
2 /*
3  QoreSSLCertificate.h
4 
5  Qore Programming Language
6 
7  Copyright (C) 2003 - 2022 Qore Technologies, s.r.o.
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 public:
45 
47  DLLEXPORT QoreSSLCertificate(X509* c);
48 
50 
53  DLLEXPORT QoreSSLCertificate(const BinaryNode* bin, ExceptionSink* xsink);
54 
56 
59  DLLEXPORT QoreSSLCertificate(const QoreString* str, ExceptionSink* xsink);
60 
62 
65  DLLLOCAL QoreSSLCertificate(const char* fn, ExceptionSink* xsink);
66 
68  DLLEXPORT operator bool() const;
69 
71 
73  DLLEXPORT QoreStringNode* getPEM(ExceptionSink* xsink) const;
74 
76 
80  DLLEXPORT BinaryNode* getDER(ExceptionSink* xsink) const;
81 
82  // caller does NOT own the X509 pointer returned; "const" cannot be used because of the openssl API does not support it
83  DLLEXPORT X509* getData() const;
84 
85  // caller owns value returned
86  DLLEXPORT QoreHashNode* getSubjectHash() const;
87 
88  // caller owns value returned
89  DLLEXPORT QoreHashNode* getIssuerHash() const;
90  DLLEXPORT int64 getSerialNumber() const;
91  DLLEXPORT int64 getVersion() const;
92 
93  // caller owns value returned
94  DLLEXPORT QoreHashNode* getPurposeHash() const;
95 
96  // caller owns value returned
97  DLLEXPORT DateTimeNode* getNotBeforeDate() const;
98 
99  // caller owns value returned
100  DLLEXPORT DateTimeNode* getNotAfterDate() const;
101 
102  // caller owns value returned
103  DLLEXPORT QoreStringNode* getSignatureType() const;
104 
105  // caller owns value returned
106  DLLEXPORT BinaryNode* getSignature() const;
107 
108  // caller owns value returned
109  DLLEXPORT QoreStringNode* getPublicKeyAlgorithm() const;
110 
111  // caller owns value returned
112  DLLEXPORT BinaryNode* getPublicKey() const;
113 
114  // caller owns value returned
115  DLLEXPORT QoreHashNode* getInfo() const;
116 
117  // caller owns reference returned
118  DLLEXPORT QoreSSLCertificate* certRefSelf() const;
119 
120 protected:
122  DLLLOCAL virtual ~QoreSSLCertificate();
123 
124 private:
126  hashdecl qore_sslcert_private* priv;
127 
128  DLLLOCAL QoreValue doPurposeValue(int id, int ca) const;
129 
131  DLLLOCAL QoreSSLCertificate(const QoreSSLCertificate&) = delete;
132 
134  DLLLOCAL QoreSSLCertificate& operator=(const QoreSSLCertificate&) = delete;
135 };
136 
137 #endif
the base class for all data to be used as private data of Qore objects
Definition: AbstractPrivateData.h:44
holds arbitrary binary data
Definition: BinaryNode.h:41
Qore's parse tree/value type for date-time values, reference-counted, dynamically-allocated only.
Definition: DateTimeNode.h:45
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:48
This is the hash or associative list container type in Qore, dynamically allocated only,...
Definition: QoreHashNode.h:50
offers static functions to help with translating openssl data structures to Qore data structures
Definition: QoreSSLBase.h:40
represents an X509 certificate, reference-counted, dynamically-allocated only
Definition: QoreSSLCertificate.h:42
DLLEXPORT QoreSSLCertificate(X509 *c)
creates the object from a pointer to an X509 data structure, the QoreSSLCertificate object takes owne...
virtual DLLLOCAL ~QoreSSLCertificate()
the destructor is protected to ensure that it's only dynamically allocated (use deref() to delete)
DLLEXPORT QoreStringNode * getPEM(ExceptionSink *xsink) const
returns a string in PEM format representing the certificate; caller owns the QoreStringNode reference...
DLLEXPORT BinaryNode * getDER(ExceptionSink *xsink) const
returns a binary in DER format representing the certificate, caller owns the BinaryNode reference cou...
Qore's string type supported by the QoreEncoding class.
Definition: QoreString.h:93
Qore's string value type, reference counted, dynamically-allocated only.
Definition: QoreStringNode.h:50
long long int64
64bit integer type, cannot use int64_t here since it breaks the API on some 64-bit systems due to equ...
Definition: common.h:260
The main value class in Qore, designed to be passed by value.
Definition: QoreValue.h:275