• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeio/kssl
 

tdeio/kssl

  • tdeio
  • kssl
ksslcertificatefactory.cpp
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 
27 KSSLCertificate*
28 KSSLCertificateFactory::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 
KSSLCertificate::setCert
bool setCert(TQString &cert)
Re-set the certificate from a base64 string.
Definition: ksslcertificate.cpp:1151
KSSLCertificate
KDE X.509 Certificate.
Definition: ksslcertificate.h:77

tdeio/kssl

Skip menu "tdeio/kssl"
  • Main Page
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

tdeio/kssl

Skip menu "tdeio/kssl"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeio/kssl by doxygen 1.8.8
This website is maintained by Timothy Pearson.