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

KIO

  • kio
  • kssl
ksslsession.cpp
Go to the documentation of this file.
1/* This file is part of the KDE project
2 *
3 * Copyright (C) 2003 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 "ksslsession.h"
22
23#include <config.h>
24#include <ksslconfig.h>
25
26#include <kopenssl.h>
27#include <kcodecs.h>
28
29KSSLSession::KSSLSession() : _session(0L) {
30}
31
32
33KSSLSession::~KSSLSession() {
34#ifdef KSSL_HAVE_SSL
35 if (_session) {
36 KOpenSSLProxy::self()->SSL_SESSION_free(static_cast<SSL_SESSION*>(_session));
37 _session = 0L;
38 }
39#endif
40}
41
42
43QString KSSLSession::toString() const {
44 QString rc;
45#ifdef KSSL_HAVE_SSL
46 SSL_SESSION *session = static_cast<SSL_SESSION*>(_session);
47 int slen = KOpenSSLProxy::self()->i2d_SSL_SESSION(session, 0L);
48
49 if (slen >= 0) {
50 // These should technically be unsigned char * but it doesn't matter
51 // for our purposes
52 char *csess = new char[slen];
53 unsigned char *p = (unsigned char*)csess;
54
55 if (!KOpenSSLProxy::self()->i2d_SSL_SESSION(session, &p)) {
56 delete[] csess;
57 return QString();
58 }
59
60 // encode it into a QString
61 rc = QByteArray(csess,slen).toBase64();
62 delete[] csess;
63 }
64#endif
65 return rc;
66}
67
68
69KSSLSession *KSSLSession::fromString(const QString& s) {
70KSSLSession *session = 0L;
71#ifdef KSSL_HAVE_SSL
72QByteArray qba, qbb = s.toLocal8Bit();
73 qba = QByteArray::fromBase64(qbb);
74 unsigned char *qbap = reinterpret_cast<unsigned char *>(qba.data());
75 SSL_SESSION *ss = KOSSL::self()->d2i_SSL_SESSION(0L, &qbap, qba.size());
76 if (ss) {
77 session = new KSSLSession;
78 session->_session = ss;
79 }
80#endif
81return session;
82}
83
84
KOpenSSLProxy::self
static KOpenSSLProxy * self()
Return an instance of class KOpenSSLProxy * You cannot delete this object.
Definition: kopenssl.cpp:722
KSSLSession
KDE SSL Session Information.
Definition: ksslsession.h:42
KSSLSession::~KSSLSession
~KSSLSession()
Destroy this instance.
Definition: ksslsession.cpp:33
KSSLSession::_session
void * _session
Definition: ksslsession.h:65
KSSLSession::toString
QString toString() const
Convert to a base64 encoded string (so it can be copied safely)
Definition: ksslsession.cpp:43
KSSLSession::fromString
static KSSLSession * fromString(const QString &s)
Create as session ID object from a base64 encoded string.
Definition: ksslsession.cpp:69
KSSLSession::KSSLSession
KSSLSession()
Definition: ksslsession.cpp:29
kcodecs.h
kopenssl.h
ksslsession.h
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