@@ -9,6 +9,7 @@ const Logger = require('../utils/logger');
|
|||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
// Simple XML stream parser
|
// Simple XML stream parser
|
||||||
class StreamParser extends EventEmitter {
|
class StreamParser extends EventEmitter {
|
||||||
@@ -346,18 +347,47 @@ class XMPPStream extends EventEmitter {
|
|||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const keyPath = tlsConfig.keyPath || '/home/ale/projects/xmpp/prosody-nodejs/certs/localhost-key.pem';
|
// Try multiple possible locations for certificates
|
||||||
const certPath = tlsConfig.certPath || '/home/ale/projects/xmpp/prosody-nodejs/certs/localhost.pem';
|
const possiblePaths = [
|
||||||
|
tlsConfig.keyPath || path.join(__dirname, '../../certs/localhost-key.pem'),
|
||||||
|
path.join(process.cwd(), 'certs/localhost-key.pem'),
|
||||||
|
'/home/ale/projects/xmpp/prosody-nodejs/certs/localhost-key.pem'
|
||||||
|
];
|
||||||
|
|
||||||
if (fs.existsSync(keyPath) && fs.existsSync(certPath)) {
|
const possibleCertPaths = [
|
||||||
|
tlsConfig.certPath || path.join(__dirname, '../../certs/localhost.pem'),
|
||||||
|
path.join(process.cwd(), 'certs/localhost.pem'),
|
||||||
|
'/home/ale/projects/xmpp/prosody-nodejs/certs/localhost.pem'
|
||||||
|
];
|
||||||
|
|
||||||
|
let keyPath = null;
|
||||||
|
let certPath = null;
|
||||||
|
|
||||||
|
// Find the first existing key file
|
||||||
|
for (const p of possiblePaths) {
|
||||||
|
if (fs.existsSync(p)) {
|
||||||
|
keyPath = p;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the first existing cert file
|
||||||
|
for (const p of possibleCertPaths) {
|
||||||
|
if (fs.existsSync(p)) {
|
||||||
|
certPath = p;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (keyPath && certPath) {
|
||||||
options.key = fs.readFileSync(keyPath);
|
options.key = fs.readFileSync(keyPath);
|
||||||
options.cert = fs.readFileSync(certPath);
|
options.cert = fs.readFileSync(certPath);
|
||||||
this.logger.debug('Using configured TLS certificates');
|
this.logger.debug(`Loaded TLS certificates from ${keyPath}`);
|
||||||
} else {
|
} else {
|
||||||
this.logger.warn('TLS certificates not found, using default options');
|
this.logger.warn(`TLS certificates not found (checked: ${possiblePaths[0]}, ${possibleCertPaths[0]})`);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.warn('Error loading TLS certificates:', error);
|
this.logger.warn('Error loading TLS certificates:', error.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
|
|||||||
Referencia en una nueva incidencia
Block a user