pike.git
/
lib
/
modules
/
SSL.pmod
/
https.pike
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/lib/modules/SSL.pmod/https.pike:8:
#endif #ifdef SSL3_DEBUG #define SSL3_DEBUG_MSG(X ...) werror(X) #else /*! SSL3_DEBUG */ #define SSL3_DEBUG_MSG(X ...) #endif /* SSL3_DEBUG */ import Stdio;
+
class MyContext
+
{
+
inherit SSL.context;
+
+
SSL.alert alert_factory(SSL.connection con,
+
int level, int description,
+
SSL.Constants.ProtocolVersion version,
+
string|void message, mixed|void trace)
+
{
+
if (message) {
+
werror("ALERT [%s: %d:%d]: %s",
+
SSL.Constants.fmt_version(version),
+
level, description, message);
+
}
+
return ::alert_factory(con, level, description, version, message, trace);
+
}
+
}
+
#ifndef HTTPS_CLIENT SSL.sslport port; void my_accept_callback(object f) {
-
werror("Accept!\n");
+
conn(port->accept()); } #endif class conn { import Stdio; object sslfile; string message =
pike.git/lib/modules/SSL.pmod/https.pike:131:
werror("Data: %O\n", data); } void con_closed() { werror("Connection closed.\n"); exit(0); } protected void create(Stdio.File con) {
-
SSL.context ctx =
SSL.context
();
+
SSL.context ctx =
MyContext
();
ctx->random = no_random()->read; // Make sure all cipher suites are available. ctx->preferred_suites = ctx->get_suites(-1, 2); werror("Starting\n"); ssl = SSL.sslfile(con, ctx, 1); ssl->set_nonblocking(got_data, write_cb, con_closed); } } int main() { #ifdef HTTPS_CLIENT Stdio.File con = Stdio.File(); if (!con->connect("127.0.0.1", PORT)) { werror("Failed to connect to server: %s\n", strerror(con->errno())); return 17; } client(con); return -17; #else
-
SSL.context ctx =
SSL.context
();
+
SSL.context ctx =
MyContext
();
Crypto.Sign key; string certificate; key = Crypto.RSA()->generate_key(1024); certificate = Standards.X509.make_selfsigned_certificate(key, 3600*4, ([ "organizationName" : "Test", "commonName" : "*", ]));