• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KIO

  • kio
  • kssl
ksslcertificatefactory.cpp
Go to the documentation of this file.
1/* This file is part of the KDE project
2 *
3 * Copyright (C) 2000 George Staikos <staikos@kde.org>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21#include <ksslcertificatefactory.h>
22#include <ksslcertificate.h>
23#include <stdlib.h>
24
25//#include <kopenssl.h>
26
27KSSLCertificate*
28KSSLCertificateFactory::generateSelfSigned(KSSLKeyType /*keytype*/) {
29#if 0
30 //#ifdef KSSL_HAVE_SSL
31 X509_NAME *x509name = X509_NAME_new();
32 X509 *x509;
33 ASN1_UTCTIME *beforeafter;
34 KSSLCertificate *newcert;
35 int rc;
36
37 // FIXME: generate the private key
38 if (keytype == KEYTYPE_UNKNOWN || (key=EVP_PKEY_new()) == NULL) {
39 X509_NAME_free(x509name);
40 return NULL;
41 }
42
43 switch(keytype) {
44 case KEYTYPE_RSA:
45 if (!EVP_PKEY_assign_RSA(key, RSA_generate_key(newkey,0x10001,
46 req_cb,bio_err))) {
47
48 }
49 break;
50 case KEYTYPE_DSA:
51 if (!DSA_generate_key(dsa_params)) goto end;
52 if (!EVP_PKEY_assign_DSA(pkey,dsa_params)) goto end;
53 dsa_params=NULL;
54 if (pkey->type == EVP_PKEY_DSA)
55 digest=EVP_dss1();
56 break;
57 }
58
59 // FIXME: dn doesn't exist
60 // FIXME: allow the notAfter value to be parameterized
61 // FIXME: allow a password to lock the key with
62
63 // Fill in the certificate
64 X509_NAME_add_entry_by_NID(x509name, OBJ_txt2nid("CN"), 0x1001,
65 (unsigned char *) dn, -1, -1, 0);
66
67 x509 = X509_new();
68 rc = X509_set_issuer_name(x509, x509name);
69 if (rc != 0) {
70 X509_free(x509);
71 X509_NAME_free(x509name);
72 return NULL;
73 }
74 rc = X509_set_subject_name(x509, x509name);
75 if (rc != 0) {
76 X509_free(x509);
77 X509_NAME_free(x509name);
78 return NULL;
79 }
80 ASN1_INTEGER_set(X509_get_serialNumber(*x509), 0);
81
82 X509_NAME_free(x509name);
83
84 // Make it a 1 year certificate
85 beforeafter = ASN1_UTCTIME_new();
86 if (!X509_gmtime_adj(beforeafter, -60*60*24)) { // yesterday
87 X509_free(x509);
88 return NULL;
89 }
90 if (!X509_set_notBefore(x509, beforeafter)) {
91 X509_free(x509);
92 return NULL;
93 }
94 if (!X509_gmtime_adj(beforeafter, 60*60*24*364)) { // a year from yesterday
95 X509_free(x509);
96 return NULL;
97 }
98 if (!X509_set_notAfter(x509, beforeafter)) {
99 X509_free(x509);
100 return NULL;
101 }
102 ASN1_UTCTIME_free(beforeafter);
103
104 if (!X509_set_pubkey(x509, key)) {
105 X509_free(x509);
106 return NULL;
107 }
108
109 rc = X509_sign(x509, key, EVP_sha1());
110 if (rc != 0) {
111 X509_free(x509);
112 return NULL;
113 }
114
115 newCert = new KSSLCertificate;
116 newCert->setCert(x509);
117 return newCert;
118#else
119 return NULL;
120#endif
121}
122
KSSLCertificateFactory::generateSelfSigned
static KSSLCertificate * generateSelfSigned(KSSLKeyType keytype)
Definition: ksslcertificatefactory.cpp:28
KSSLCertificate
KDE X.509 Certificate.
Definition: ksslcertificate.h:75
KSSLCertificate::setCert
bool setCert(const QString &cert)
Re-set the certificate from a base64 string.
Definition: ksslcertificate.cpp:1273
ksslcertificate.h
ksslcertificatefactory.h
KSSLKeyType
KSSLKeyType
Definition: ksslcertificatefactory.h:30
KEYTYPE_UNKNOWN
@ KEYTYPE_UNKNOWN
Definition: ksslcertificatefactory.h:30
KEYTYPE_DSA
@ KEYTYPE_DSA
Definition: ksslcertificatefactory.h:30
KEYTYPE_RSA
@ KEYTYPE_RSA
Definition: ksslcertificatefactory.h:30
end
const KShortcut & end()
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KIO

Skip menu "KIO"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal