Qore Programming Language 2.1.1
Loading...
Searching...
No Matches
QoreSSLCertificate.h
1/* -*- mode: c++; indent-tabs-mode: nil -*- */
2/*
3 QoreSSLCertificate.h
4
5 Qore Programming Language
6
7 Copyright (C) 2003 - 2024 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
43friend class SSLSocketHelper;
44public:
46
48 DLLEXPORT QoreSSLCertificate(X509* c);
49
51
54 DLLEXPORT QoreSSLCertificate(const BinaryNode* bin, ExceptionSink* xsink);
55
57
60 DLLEXPORT QoreSSLCertificate(const QoreString* str, ExceptionSink* xsink);
61
63
66 DLLLOCAL QoreSSLCertificate(const char* fn, ExceptionSink* xsink);
67
69 DLLEXPORT operator bool() const;
70
72
74 DLLEXPORT QoreStringNode* getPEM(ExceptionSink* xsink) const;
75
77
81 DLLEXPORT BinaryNode* getDER(ExceptionSink* xsink) const;
82
83 // caller does NOT own the X509 pointer returned; "const" cannot be used because of the openssl API does not support it
84 DLLEXPORT X509* getData() const;
85
86 // caller owns value returned
87 DLLEXPORT QoreHashNode* getSubjectHash() const;
88
89 // caller owns value returned
90 DLLEXPORT QoreHashNode* getIssuerHash() const;
91 DLLEXPORT int64 getSerialNumber() const;
92 DLLEXPORT int64 getVersion() const;
93
94 // caller owns value returned
95 DLLEXPORT QoreHashNode* getPurposeHash() const;
96
97 // caller owns value returned
98 DLLEXPORT DateTimeNode* getNotBeforeDate() const;
99
100 // caller owns value returned
101 DLLEXPORT DateTimeNode* getNotAfterDate() const;
102
103 // caller owns value returned
104 DLLEXPORT QoreStringNode* getSignatureType() const;
105
106 // caller owns value returned
107 DLLEXPORT BinaryNode* getSignature() const;
108
109 // caller owns value returned
110 DLLEXPORT QoreStringNode* getPublicKeyAlgorithm() const;
111
112 // caller owns value returned
113 DLLEXPORT BinaryNode* getPublicKey() const;
114
115 // caller owns value returned
116 DLLEXPORT QoreHashNode* getInfo() const;
117
118 // caller owns reference returned
119 DLLEXPORT QoreSSLCertificate* certRefSelf() const;
120
121protected:
123 DLLLOCAL virtual ~QoreSSLCertificate();
124
125private:
127 hashdecl qore_sslcert_private* priv;
128
129 DLLLOCAL QoreValue doPurposeValue(int id, int ca) const;
130
132 DLLLOCAL QoreSSLCertificate(const QoreSSLCertificate&) = delete;
133
135 DLLLOCAL QoreSSLCertificate& operator=(const QoreSSLCertificate&) = delete;
136};
137
138#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:47
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition ExceptionSink.h:50
This is the hash or associative list container type in Qore, dynamically allocated only,...
Definition QoreHashNode.h:51
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(const QoreString *str, ExceptionSink *xsink)
create the object from a pointer to a QoreString representing the X.509 certificate in PEM format
DLLLOCAL QoreSSLCertificate(const char *fn, ExceptionSink *xsink)
creates the object from a filename
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 QoreSSLCertificate(const BinaryNode *bin, ExceptionSink *xsink)
creates the object from a pointer to a BinaryNode object (certificate data in DER format)
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:266
The main value class in Qore, designed to be passed by value.
Definition QoreValue.h:279