Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added sample certificate files for easier installation

  • Loading branch information...
commit e5f449e2eb6fc0de6c62bdf2788e8d5840878407 1 parent 37f87f8
andris9 authored
View
4 README.md
@@ -29,7 +29,9 @@ Usage
openssl req -new -key privatekey.pem -out certrequest.csr
openssl x509 -req -in certrequest.csr -signkey privatekey.pem -out certificate.pem
-2. Update *pop3_server.js* to set the location of the certificate files (privatekey.pem and certificate.pem), default location: "../cert/"
+ There are already example certificate files in "/cert" for a kickstart installation but you should probably still genereate your own.
+
+2. Copy privatekey.pem and certificate.pem to "/cert" (overwrite the sample certificate files)
3. Run *pop3_server.js* and add a POP3 account to your e-mail client pointing to the node.js server. With the demo script usernames don't matter, any name goes, but the password needs to be 12345
View
17 cert/certificate.pem
@@ -0,0 +1,17 @@
+-----BEGIN CERTIFICATE-----
+MIICqzCCAhQCCQDq6l4dTfOkJjANBgkqhkiG9w0BAQUFADCBmTELMAkGA1UEBhMC
+WFgxETAPBgNVBAgTCEFueXN0YXRlMRAwDgYDVQQHEwdBbnl0b3duMRUwEwYDVQQK
+EwxBbnljb3JwIEx0ZC4xEzARBgNVBAsTCnBvcDNzZXJ2ZXIxEjAQBgNVBAMTCWxv
+Y2FsaG9zdDElMCMGCSqGSIb3DQEJARYWaW5mb0BjcmVhdHlvdXJvd24uY2VydDAe
+Fw0xMDA5MTQxMzU5MzRaFw0xMDEwMTQxMzU5MzRaMIGZMQswCQYDVQQGEwJYWDER
+MA8GA1UECBMIQW55c3RhdGUxEDAOBgNVBAcTB0FueXRvd24xFTATBgNVBAoTDEFu
+eWNvcnAgTHRkLjETMBEGA1UECxMKcG9wM3NlcnZlcjESMBAGA1UEAxMJbG9jYWxo
+b3N0MSUwIwYJKoZIhvcNAQkBFhZpbmZvQGNyZWF0eW91cm93bi5jZXJ0MIGfMA0G
+CSqGSIb3DQEBAQUAA4GNADCBiQKBgQC77Set/Y18FkYvpQuS+wt906alW3tzVjT/
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uwQ5zNLdcCQQCT
+FzKOw5eUCOa5ka4N6cunRjt+zuFr/RvRQ/UujtFfiHjkrnVXDTjVnUuaSvCRpRYm
+5+UuUMM2xpJ9tiCo+sBpAkEAmFSZzmojshamvgn8pcPRt2KwvqaEP+Q4bvPZI20X
+F+ISFTscxHMkMYCAhBV/dSsm1X3GP+emaZbE0TG8cUhupA==
+-----END RSA PRIVATE KEY-----
View
26 n3.js
@@ -140,8 +140,6 @@ var N3 = {
key: privateKey.toString("ascii"),
cert: certificate.toString("ascii")
});
- this.capabilities[1].unshift("STLS");
- this.capabilities[2].unshift("STLS");
}
net.createServer(this.createInstance.bind(
@@ -162,6 +160,20 @@ var N3 = {
this.authCallback = auth;
this.MsgStore = MsgStore;
this.credentials = credentials;
+ this.connection_secured = false;
+
+ // Copy N3 capabilities info into the current object
+ this.capabilities = {
+ 1: Object.create(N3.capabilities[1]),
+ 2: Object.create(N3.capabilities[2]),
+ 3: Object.create(N3.capabilities[3])
+ }
+
+ // announce STARTLS support
+ if(!useTLS && credentials){
+ this.capabilities[1].unshift("STLS");
+ this.capabilities[2].unshift("STLS");
+ }
if(useTLS && credentials)
socket.setSecure(credentials);
@@ -171,9 +183,10 @@ var N3 = {
socket.on("data", this.onData.bind(this));
socket.on("end", this.onEnd.bind(this));
- socket.on("secure", function(){
+ socket.on("secure", (function(){
console.log("Secure connection successfully established")
- });
+ this.connection_secured = true;
+ }).bind(this));
},
foldLines: function(str, anywhere){
@@ -347,8 +360,8 @@ N3.POP3Server.prototype.onCommand = function(request){
// CAPA - Reveals server capabilities to the client
N3.POP3Server.prototype.cmdCAPA = function(){
this.response("+OK Capability list follows");
- for(var i=0;i<N3.capabilities[this.state].length; i++){
- this.response(N3.capabilities[this.state][i]);
+ for(var i=0;i<this.capabilities[this.state].length; i++){
+ this.response(this.capabilities[this.state][i]);
}
this.response(".");
}
@@ -366,6 +379,7 @@ N3.POP3Server.prototype.cmdQUIT = function(){
// STLS - ENTER SECURE TLS MODE
N3.POP3Server.prototype.cmdSTLS = function(){
if(!this.credentials) return this.response("-ERR Not implemented");
+ if(this.connconnection_secured) return this.response("-ERR TLS already established");
this.response("+OK Begin TLS negotiation now");
this.socket.setSecure(this.credentials);
console.log("Entered secure connection mode (TLS)")
View
4 pop3_server.js
@@ -1,8 +1,8 @@
var n3 = require("./n3"),
server_name = "node.ee",
- pkFilename = "../cert/privatekey.pem",
- crtFilename = "../cert/certificate.pem";
+ pkFilename = "./cert/privatekey.pem",
+ crtFilename = "./cert/certificate.pem";
// use markdown parser to create HTML message
try{
Please sign in to comment.
Something went wrong with that request. Please try again.