mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-23 00:13:13 +09:00
Fixed SSL test failing
This commit is contained in:
1 parent
0688184aaf
commit
fdd8a8299b
2 files changed
+10
-6
No files matched your search
@@ -7,18 +7,22 @@ var pki = forge.pki;
|
|||||||
var rsa = forge.pki.rsa;
|
var rsa = forge.pki.rsa;
|
||||||
var startTime, endTime;
|
var startTime, endTime;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = function({
|
module.exports = function({
|
||||||
bits = 2048,
|
bits = 2048,
|
||||||
certificatePath = "database/certificate",
|
certificatePath = "database/certificate",
|
||||||
doLogging = false,
|
doLogging = false,
|
||||||
} = {}){
|
} = {}){
|
||||||
if(!doLogging) console.log = function(){};
|
function log(t){
|
||||||
console.log("Generating SSL certificate with "+bits+" bits at "+certificatePath);
|
if(doLogging) console.log("lib/generateSSLcert.js | "+t);
|
||||||
|
}
|
||||||
|
log("Generating SSL certificate with "+bits+" bits at "+certificatePath);
|
||||||
|
|
||||||
startTime = Date.now();
|
startTime = Date.now();
|
||||||
var keypair = rsa.generateKeyPair({bits: bits, e: 0x10001});
|
var keypair = rsa.generateKeyPair({bits: bits, e: 0x10001});
|
||||||
endTime = Date.now();
|
endTime = Date.now();
|
||||||
console.log("Generated 2048bit keypair in: "+(endTime-startTime)+" ms");
|
log("Generated 2048bit keypair in: "+(endTime-startTime)+" ms");
|
||||||
|
|
||||||
startTime = Date.now();
|
startTime = Date.now();
|
||||||
var cert = pki.createCertificate();
|
var cert = pki.createCertificate();
|
||||||
@@ -37,9 +41,9 @@ module.exports = function({
|
|||||||
mkdirp.sync(certificatePath);
|
mkdirp.sync(certificatePath);
|
||||||
console.log("Created directory: "+certificatePath);
|
console.log("Created directory: "+certificatePath);
|
||||||
}
|
}
|
||||||
fs.writeFileSync(certificatePath+ "cert.key", pki.privateKeyToPem(keypair.privateKey)); /////////////////// THIS WRITES [object object]
|
fs.writeFileSync(certificatePath+ "cert.key", pki.privateKeyToPem(keypair.privateKey));
|
||||||
fs.writeFileSync(certificatePath+ "cert.crt", pki.certificateToPem(cert));
|
fs.writeFileSync(certificatePath+ "cert.crt", pki.certificateToPem(cert));
|
||||||
|
|
||||||
endTime = Date.now();
|
endTime = Date.now();
|
||||||
console.log("Generated certificate in: "+(endTime-startTime)+" ms");
|
log("Generated certificate in: "+(endTime-startTime)+" ms");
|
||||||
}
|
}
|
||||||
@@ -7,12 +7,12 @@ var generateSSLcert = require("./generateSSLcert.js")
|
|||||||
describe("generateSSLcert.js(options)", ()=>{
|
describe("generateSSLcert.js(options)", ()=>{
|
||||||
it("Creates a folder with a .crt and .key file in it", ()=>{
|
it("Creates a folder with a .crt and .key file in it", ()=>{
|
||||||
let certPath = "lib/certTestPlsDelete";
|
let certPath = "lib/certTestPlsDelete";
|
||||||
|
|
||||||
assert(!fs.existsSync(certPath)); // if it already exsits, the test might pass because of leftover data (which is bad)
|
assert(!fs.existsSync(certPath)); // if it already exsits, the test might pass because of leftover data (which is bad)
|
||||||
|
|
||||||
generateSSLcert({
|
generateSSLcert({
|
||||||
// bits:512, // supported, but I just use the default of 2048 for this test
|
// bits:512, // supported, but I just use the default of 2048 for this test
|
||||||
certificatePath:certPath,
|
certificatePath:certPath,
|
||||||
|
doLogging: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
assert(fs.existsSync(certPath));
|
assert(fs.existsSync(certPath));
|
||||||
|
|||||||
Reference in new issue
Block a user