@@ -9,6 +9,7 @@ const Logger = require('../utils/logger');
|
||||
const crypto = require('crypto');
|
||||
const tls = require('tls');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
// Simple XML stream parser
|
||||
class StreamParser extends EventEmitter {
|
||||
@@ -346,18 +347,47 @@ class XMPPStream extends EventEmitter {
|
||||
};
|
||||
|
||||
try {
|
||||
const keyPath = tlsConfig.keyPath || '/home/ale/projects/xmpp/prosody-nodejs/certs/localhost-key.pem';
|
||||
const certPath = tlsConfig.certPath || '/home/ale/projects/xmpp/prosody-nodejs/certs/localhost.pem';
|
||||
// Try multiple possible locations for certificates
|
||||
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.cert = fs.readFileSync(certPath);
|
||||
this.logger.debug('Using configured TLS certificates');
|
||||
this.logger.debug(`Loaded TLS certificates from ${keyPath}`);
|
||||
} 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) {
|
||||
this.logger.warn('Error loading TLS certificates:', error);
|
||||
this.logger.warn('Error loading TLS certificates:', error.message);
|
||||
}
|
||||
|
||||
return options;
|
||||
|
||||
Referencia en una nueva incidencia
Block a user