master
h 110 lines 3.46 KB
Raw
1 /*
2 * QEMU crypto TLS x509 credential support
3 *
4 * Copyright (c) 2015 Red Hat, Inc.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21 #ifndef QCRYPTO_TLSCREDSX509_H
22 #define QCRYPTO_TLSCREDSX509_H
23
24 #include "crypto/tlscreds.h"
25 #include "qom/object.h"
26
27 #define TYPE_QCRYPTO_TLS_CREDS_X509 "tls-creds-x509"
28 typedef struct QCryptoTLSCredsX509 QCryptoTLSCredsX509;
29 DECLARE_INSTANCE_CHECKER(QCryptoTLSCredsX509, QCRYPTO_TLS_CREDS_X509,
30 TYPE_QCRYPTO_TLS_CREDS_X509)
31
32 typedef struct QCryptoTLSCredsX509Class QCryptoTLSCredsX509Class;
33
34 #define QCRYPTO_TLS_CREDS_X509_CA_CERT "ca-cert.pem"
35 #define QCRYPTO_TLS_CREDS_X509_CA_CRL "ca-crl.pem"
36 #define QCRYPTO_TLS_CREDS_X509_SERVER_KEY "server-key.pem"
37 #define QCRYPTO_TLS_CREDS_X509_SERVER_CERT "server-cert.pem"
38 #define QCRYPTO_TLS_CREDS_X509_CLIENT_KEY "client-key.pem"
39 #define QCRYPTO_TLS_CREDS_X509_CLIENT_CERT "client-cert.pem"
40 #define QCRYPTO_TLS_CREDS_X509_SERVER_KEY_N "server-key-%zu.pem"
41 #define QCRYPTO_TLS_CREDS_X509_SERVER_CERT_N "server-cert-%zu.pem"
42 #define QCRYPTO_TLS_CREDS_X509_CLIENT_KEY_N "client-key-%zu.pem"
43 #define QCRYPTO_TLS_CREDS_X509_CLIENT_CERT_N "client-cert-%zu.pem"
44
45 /* Max number of additional cert/key pairs (ie _N constants) */
46 #define QCRYPTO_TLS_CREDS_X509_IDENTITY_MAX 4
47
48 /**
49 * QCryptoTLSCredsX509:
50 *
51 * The QCryptoTLSCredsX509 object provides a representation
52 * of x509 credentials used to perform a TLS handshake.
53 *
54 * This is a user creatable object, which can be instantiated
55 * via object_new_propv():
56 *
57 * <example>
58 * <title>Creating x509 TLS credential objects in code</title>
59 * <programlisting>
60 * Object *obj;
61 * Error *err = NULL;
62 * obj = object_new_propv(TYPE_QCRYPTO_TLS_CREDS_X509,
63 * "tlscreds0",
64 * &err,
65 * "endpoint", "server",
66 * "dir", "/path/x509/cert/dir",
67 * "verify-peer", "yes",
68 * NULL);
69 * </programlisting>
70 * </example>
71 *
72 * Or via QMP:
73 *
74 * <example>
75 * <title>Creating x509 TLS credential objects via QMP</title>
76 * <programlisting>
77 * {
78 * "execute": "object-add", "arguments": {
79 * "id": "tlscreds0",
80 * "qom-type": "tls-creds-x509",
81 * "props": {
82 * "endpoint": "server",
83 * "dir": "/path/to/x509/cert/dir",
84 * "verify-peer": false
85 * }
86 * }
87 * }
88 * </programlisting>
89 * </example>
90 *
91 *
92 * Or via the CLI:
93 *
94 * <example>
95 * <title>Creating x509 TLS credential objects via CLI</title>
96 * <programlisting>
97 * qemu-system-x86_64 -object tls-creds-x509,id=tlscreds0,\
98 * endpoint=server,verify-peer=off,\
99 * dir=/path/to/x509/certdir/
100 * </programlisting>
101 * </example>
102 *
103 */
104
105 struct QCryptoTLSCredsX509Class {
106 QCryptoTLSCredsClass parent_class;
107 };
108
109
110 #endif /* QCRYPTO_TLSCREDSX509_H */