[pan2/testing: 233/279] misc fixes
- From: Heinrich MÃller <henmull src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pan2/testing: 233/279] misc fixes
- Date: Sat, 3 Dec 2011 22:41:09 +0000 (UTC)
commit af2b15b03c93a184b83af40b9903c7e0de656396
Author: Heinrich MÃller <sphemuel stud informatik uni-erlangen de>
Date: Mon Nov 7 16:07:09 2011 +0100
misc fixes
pan/tasks/cert-store.h | 16 ++++++++++++++++
pan/tasks/socket-impl-main.cc | 1 +
pan/tasks/socket-impl-openssl.cc | 26 ++++++++++++++++++++++----
pan/tasks/socket-impl-openssl.h | 1 +
pan/usenet-utils/url-find.cc | 6 ++++--
5 files changed, 44 insertions(+), 6 deletions(-)
---
diff --git a/pan/tasks/cert-store.h b/pan/tasks/cert-store.h
index e50fabe..9105b8e 100644
--- a/pan/tasks/cert-store.h
+++ b/pan/tasks/cert-store.h
@@ -57,6 +57,7 @@ namespace pan
certs_m _cert_to_server;
X509_STORE* _store;
std::string _path;
+ std::vector<SSL_SESSION*> _sessions;
public:
SSL_CTX* get_ctx() { return _ctx; }
@@ -64,6 +65,21 @@ namespace pan
void get_all_certs_from_disk(std::set<X509*>& setme);
const X509* get_cert_to_server(const Quark& server) const;
static void pretty_print_x509 (char* buf, size_t size, const Quark& server, X509* cert);
+ SSL_SESSION* get_session()
+ {
+ SSL_SESSION* ret(0);
+ if (!_sessions.empty())
+ {
+ ret = _sessions.back();
+ _sessions.pop_back();
+ }
+ return ret;
+ }
+ void add_session (SSL_SESSION* s)
+ {
+ if (!s) return;
+ _sessions.push_back(s);
+ }
private:
void remove_hard(const Quark&);
diff --git a/pan/tasks/socket-impl-main.cc b/pan/tasks/socket-impl-main.cc
index c5584aa..afb0913 100644
--- a/pan/tasks/socket-impl-main.cc
+++ b/pan/tasks/socket-impl-main.cc
@@ -136,6 +136,7 @@ SocketCreator :: SocketCreator(CertStore& cs) : store(cs)
ssl_ctx = SSL_CTX_new(SSLv3_client_method());
cs.set_ctx(ssl_ctx);
SSL_CTX_set_mode(ssl_ctx, SSL_MODE_ENABLE_PARTIAL_WRITE | SSL_MODE_AUTO_RETRY);
+ SSL_CTX_set_session_cache_mode(ssl_ctx, SSL_SESS_CACHE_CLIENT);
#endif
}
diff --git a/pan/tasks/socket-impl-openssl.cc b/pan/tasks/socket-impl-openssl.cc
index eeb776b..59a79a1 100644
--- a/pan/tasks/socket-impl-openssl.cc
+++ b/pan/tasks/socket-impl-openssl.cc
@@ -125,6 +125,7 @@ GIOChannelSocketSSL :: GIOChannelSocketSSL (SSL_CTX* ctx, CertStore& cs):
{
// std::cerr<<"GIOChannelSocketSSL ctor " << (void*)this<<std::endl;
cs.add_listener(this);
+ _session = cs.get_session();
}
@@ -295,10 +296,17 @@ namespace
GIOChannelSocketSSL :: ~GIOChannelSocketSSL ()
{
-// std::cerr << LINE_ID << " destroying socket " << this << std::endl;
-
_certstore.remove_listener(this);
+ GIOSSLChannel *chan = (GIOSSLChannel *)_channel;
+
+ std::cerr << LINE_ID << " destroying socket " << this << ", "<<chan->ssl<<", "<<_session<<", ";
+
+ _session = SSL_get1_session(chan->ssl);
+ _certstore.add_session(_session);
+
+ std::cerr<<_session<<std::endl;
+
remove_source (_tag_watch);
remove_source (_tag_timeout);
@@ -367,7 +375,7 @@ namespace
}
- int ssl_handshake(GIOChannel *handle, CertStore::Listener* listener, CertStore* cs, std::string host)
+ int ssl_handshake(GIOChannel *handle, CertStore::Listener* listener, CertStore* cs, std::string host, SSL_SESSION* session)
{
GIOSSLChannel *chan = (GIOSSLChannel *)handle;
@@ -385,6 +393,10 @@ namespace
mydata.server = host;
SSL_set_ex_data(chan->ssl, SSL_get_fd(chan->ssl), &mydata);
+
+ std::cerr<<"resuming session "<<session<<" for "<<chan->ssl<<std::endl;
+ if (session) SSL_set_session(chan->ssl, session);
+
ret = SSL_connect(chan->ssl);
if (ret <= 0) {
err = SSL_get_error(chan->ssl, ret);
@@ -500,6 +512,8 @@ namespace
GIOSSLChannel *chan = (GIOSSLChannel *)handle;
g_io_channel_close(chan->giochan);
+ std::cerr<<"ssl close\n";
+
return G_IO_STATUS_NORMAL;
}
@@ -778,10 +792,14 @@ GIOChannelSocketSSL :: ssl_get_iochannel(GIOChannel *handle, gboolean verify)
g_io_channel_init(gchan);
gchan->read_buf = g_string_sized_new(4096*128);
- if (ssl_handshake(gchan, this, &_certstore, _host) == 0)
+ int ret;
+ if ((ret = ssl_handshake(gchan, this, &_certstore, _host, _session)) == 0)
{
g_io_channel_set_flags (handle, G_IO_FLAG_NONBLOCK, 0);
return gchan;
+ } else
+ {
+ std::cerr<<"handshake ret "<<ret<<std::endl;
}
return 0;
}
diff --git a/pan/tasks/socket-impl-openssl.h b/pan/tasks/socket-impl-openssl.h
index 354d249..20eef27 100644
--- a/pan/tasks/socket-impl-openssl.h
+++ b/pan/tasks/socket-impl-openssl.h
@@ -70,6 +70,7 @@ namespace pan
bool _io_performed;
SSL_CTX * _ctx;
CertStore& _certstore;
+ SSL_SESSION* _session;
private:
enum WatchMode { READ_NOW, WRITE_NOW, IGNORE_NOW };
diff --git a/pan/usenet-utils/url-find.cc b/pan/usenet-utils/url-find.cc
index 8034839..58fcc93 100644
--- a/pan/usenet-utils/url-find.cc
+++ b/pan/usenet-utils/url-find.cc
@@ -33,14 +33,16 @@ namespace {
// reserved for schemas: ;/?:@=&
// % (hex encoding) # (fragment)
// allowed: a-z A-Z 0-9 $-_.+!*'(),
+ // imhotep : * removed ')' from allowed characters
+ // * added '~' & '-' to allowed characters
regex = g_regex_new("(?:"
"https?://|"
"ftps?(?:://|\\.)|" //ftp:// ftp.
"news:|nntp:|"
"www\\.|"
- "[[:alnum:]][[:alnum:]_\\.]*@" //email
+ "[[:alnum:]][[:alnum:]_+-\\.]*@" //email
")"
- "[" "[:alnum:]$_\\-\\.!+*()',%#" ";:/?&=@" "]+" /* uri */,
+ "[" "[:alnum:]$_\\-\\.!+*()',%#~" ";:/?&=@" "]+" /* uri */,
G_REGEX_OPTIMIZE, (GRegexMatchFlags)0, NULL);
}
~fooregex()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]