21 lines
665 B
JavaScript
21 lines
665 B
JavaScript
|
$(function () {
|
||
|
$('.magic-csr').click(function () {
|
||
|
var keys = forge.pki.rsa.generateKeyPair(1024);
|
||
|
var csr = forge.pki.createCertificationRequest();
|
||
|
csr.publicKey = keys.publicKey;
|
||
|
csr.setSubject([{
|
||
|
name: 'commonName',
|
||
|
value: 'eater-' + +Date.now()
|
||
|
}]);
|
||
|
csr.sign(keys.privateKey);
|
||
|
var pem = forge.pki.certificationRequestToPem(csr);
|
||
|
|
||
|
$.post('/panel/certificates/new', {
|
||
|
csr: pem
|
||
|
}, function (data) {
|
||
|
var config = data.config;
|
||
|
config = config.replace('<PUT PRIVATE KEY HERE>', forge.pki.privateKeyToPem(keys.privateKey));
|
||
|
});
|
||
|
});
|
||
|
});
|