summaryrefslogtreecommitdiff
path: root/src/gmcerts.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/gmcerts.h')
-rw-r--r--src/gmcerts.h82
1 files changed, 81 insertions, 1 deletions
diff --git a/src/gmcerts.h b/src/gmcerts.h
index a3df8f33..92a12a6a 100644
--- a/src/gmcerts.h
+++ b/src/gmcerts.h
@@ -1,8 +1,88 @@
1/* Copyright 2020 Jaakko Keränen <jaakko.keranen@iki.fi>
2
3Redistribution and use in source and binary forms, with or without
4modification, are permitted provided that the following conditions are met:
5
61. Redistributions of source code must retain the above copyright notice, this
7 list of conditions and the following disclaimer.
82. Redistributions in binary form must reproduce the above copyright notice,
9 this list of conditions and the following disclaimer in the documentation
10 and/or other materials provided with the distribution.
11
12THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
13ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
14WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
15DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
16ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
17(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
18LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
19ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
21SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
22
1#pragma once 23#pragma once
2 24
25#include <the_Foundation/ptrarray.h>
26#include <the_Foundation/stringset.h>
3#include <the_Foundation/tlsrequest.h> 27#include <the_Foundation/tlsrequest.h>
4 28
29iDeclareType(GmIdentity)
30iDeclareTypeConstruction(GmIdentity)
31iDeclareTypeSerialization(GmIdentity)
32
33enum iGmIdentityFlags {
34 temporary_GmIdentityFlag = 0x1, /* not saved persistently */
35 imported_GmIdentityFlag = 0x2, /* user-provided files */
36};
37
38struct Impl_GmIdentity {
39 iBlock fingerprint;
40 iTlsCertificate *cert;
41 iStringSet *useUrls;
42 iChar icon;
43 iString notes; /* private, local usage notes */
44 int flags;
45};
46
47iBool isUsed_GmIdentity (const iGmIdentity *);
48iBool isUsedOn_GmIdentity (const iGmIdentity *, const iString *url);
49
50void setUse_GmIdentity (iGmIdentity *, const iString *url, iBool use);
51void clearUse_GmIdentity (iGmIdentity *);
52
53const iString *name_GmIdentity(const iGmIdentity *);
54
55/*----------------------------------------------------------------------------------------------*/
56
5iDeclareType(GmCerts) 57iDeclareType(GmCerts)
6iDeclareTypeConstructionArgs(GmCerts, const char *saveDir) 58iDeclareTypeConstructionArgs(GmCerts, const char *saveDir)
7 59
8iBool checkTrust_GmCerts (iGmCerts *, iRangecc domain, const iTlsCertificate *cert); 60iBool checkTrust_GmCerts (iGmCerts *, iRangecc domain, const iTlsCertificate *cert);
61
62/**
63 * Create a new self-signed TLS client certificate for identifying the user.
64 * @a commonName and the other name parameters are inserted in the subject field
65 * of the certificate.
66 *
67 * @param flags Identity flags. A temporary identity is not saved persistently and
68 * will be erased when the application is shut down.
69 * @param validUntil Expiration date. Must be in the future.
70 *
71 * @returns Created identity. GmCerts retains ownership of returned object.
72 */
73iGmIdentity * newIdentity_GmCerts (iGmCerts *, int flags, iDate validUntil,
74 const iString *commonName, const iString *email,
75 const iString *userId, const iString *domain,
76 const iString *org, const iString *country);
77
78void deleteIdentity_GmCerts (iGmCerts *, iGmIdentity *identity);
79
80const iString * certificatePath_GmCerts (const iGmCerts *, const iGmIdentity *identity);
81
82iGmIdentity * identity_GmCerts (iGmCerts *, unsigned int id);
83const iGmIdentity * constIdentity_GmCerts (const iGmCerts *, unsigned int id);
84const iGmIdentity * identityForUrl_GmCerts (const iGmCerts *, const iString *url);
85const iPtrArray * identities_GmCerts (const iGmCerts *);
86
87void signIn_GmCerts (iGmCerts *, iGmIdentity *identity, const iString *url);
88void signOut_GmCerts (iGmCerts *, const iString *url);