HTTPS con nombre de máquina no localhost en ASP.NET Core y Node.js confía

Guía para crear certificados autofirmados con SANs (my-machine, localhost y 127.0.0.1), configurarlos en Kestrel y Node.js y confiar en navegadores para desarrollo.

20 sept 2025 • 4 min read • Q2BSTUDIO Team

Inteligencia-Artificial-

Cuando ejecutas dotnet dev-certs https --trust .NET crea y confía en un certificado de desarrollador válido solo para localhost. Eso funciona para https://localhost:1234 pero no cubre https://my-machine:1234. Si necesitas acceder a tu servicio por nombre de máquina por ejemplo https://my-machine:7164 debes generar un certificado autofirmado que incluya todos los nombres que vas a usar como SANs machine name localhost y opcionalmente 127.0.0.1 y luego configurar Kestrel para usarlo. Además debes importar y confiar ese certificado en los navegadores y decirle a Node.js cómo confiarlo. A continuación pasos claros para Windows PowerShell.

1) Crear un certificado autofirmado PFX para el nombre de tu máquina

Ejemplo de comandos PowerShell simplificados para crear un certificado con SANs

$dns = @(my-machine,localhost,127.0.0.1)

$cert = New-SelfSignedCertificate -DnsName $dns -CertStoreLocation Cert:/CurrentUser/My

$pwd = ConvertTo-SecureString YOUR-PASSWORD -AsPlainText -Force

Export-PfxCertificate -Cert $cert -FilePath C:/Users/USER/FILENAME.pfx -Password $pwd

Consejo mantener localhost y 127.0.0.1 en la lista SAN para no romper herramientas existentes.

2) Opcional reemplazar el certificado dev predeterminado de dotnet

Si quieres que tu certificado sea el dev cert global puedes limpiar e importar

dotnet dev-certs https --clean --import C:/Users/USER/FILENAME.pfx -p YOUR-PASSWORD --trust

3) O bien indicar el PFX a Kestrel desde appsettings.json

Si prefieres no tocar el certificado global configura la app explícitamente en appsettings.json con la ruta absoluta al PFX y la contraseña. Ejemplo simplificado

{ Kestrel: { Certificates: { Default: { Path: C:/Users/USER/FILENAME.pfx, Password: YOUR-PASSWORD } } } }

4) Confiar el certificado para navegadores

Exporta la parte publica a .cer e impórtala en Trusted Root Certification Authorities para Current User

$cer = C:/Users/USER/FILENAME.cer

Export-Certificate -Cert $cert -FilePath $cer

Import-Certificate -FilePath $cer -CertStoreLocation Cert:/CurrentUser/Root

Recomendación no generar directamente en la tienda Trust. Crea el cert en CurrentUser/My luego exporta e importa. Mantener el flujo reduce errores y protege la clave privada.

5) Hacer que funcione con Node.js

Node 22 no usa por defecto el almacén de confianza de Windows y no acepta .cer vía NODE_EXTRA_CA_CERTS. Convierte .cer a .pem y establece NODE_EXTRA_CA_CERTS

certutil -encode C:/Users/USER/FILENAME.cer C:/Users/USER/FILENAME.pem

En la sesión actual de PowerShell

$env:NODE_EXTRA_CA_CERTS = C:/Users/USER/FILENAME.pem

O persistir para nuevas shells

setx NODE_EXTRA_CA_CERTS C:/Users/USER/FILENAME.pem

Luego ejecutar node y fetch hacia https://my-machine:7164 ya no debería quejarse por certificado autofirmado.

Node 23.8 y superiores permiten usar directamente el almacén del sistema

node --use-system-ca tu-script.js

6) Eliminar el certificado más tarde

Si aún tienes el objeto $cert

$thumb = $cert.Thumbprint

Remove-Item Cert:/CurrentUser/My/$thumb -DeleteKey -Force

Si no tienes $cert busca por subject o issuer en Cert:/CurrentUser/My y elimina por thumbprint.

Errores comunes y recomendaciones

Nombre no coincidente la host de la URL debe estar listada en los DNS names SANs si accedes a https://my-machine:7164 my-machine debe estar en el certificado. Node sigue fallando en Node 22 asegúrate de que NODE_EXTRA_CA_CERTS apunta a un archivo PEM no a un CER reinicia la shell o setéalo en la misma sesión. Confianza en navegador importa la parte publica en Trusted Root Certification Authorities de Current User. Rutas usa rutas absolutas Windows para la propiedad Path de Kestrel.

Resumen generar un PFX autofirmado con SANs para my-machine localhost y 127.0.0.1. Importarlo como dev cert global o referenciarlo desde Kestrel. Exportar el .cer e importarlo en Trusted Root para que los navegadores confíen. En Node usar NODE_EXTRA_CA_CERTS con un .pem para Node 22 o --use-system-ca para Node 23.8 en adelante. Esto permite desarrollar y probar endpoints HTTPS usando el nombre de máquina evitando las limitaciones del alcance localhost de dotnet dev-certs.

En Q2BSTUDIO somos una empresa de desarrollo de software y aplicaciones a medida especializada en soluciones a medida inteligencia artificial ciberseguridad y servicios cloud. Ofrecemos desarrollo de aplicaciones a medida que integran agentes IA y soluciones de IA para empresas además de servicios de ciberseguridad y pentesting. Si buscas crear una solución segura y escalable consulta nuestros servicios de desarrollo en desarrollo de aplicaciones a medida y descubre cómo aplicamos inteligencia artificial para empresas en soluciones de inteligencia artificial. También trabajamos con servicios cloud aws y azure servicios inteligencia de negocio power bi y automatización de procesos para ofrecer software a medida que cubre todo el ciclo de producto.

Palabras clave aplicaciones a medida software a medida inteligencia artificial ciberseguridad servicios cloud aws y azure servicios inteligencia de negocio ia para empresas agentes IA power bi.

A BREAK?

Play for a moment before you go

OUR SERVICES

How we can help you

Artificial intelligence

AI agents, chatbots, and intelligent assistants that automate tasks and serve your customers 24/7 to improve the efficiency of your business.

More info

Software Development

Web, mobile, and desktop applications, intranets, e-commerce, SaaS, and management platforms designed for your company's specific needs.

More info

Cloud services

Migration, infrastructure, managed hosting, high availability, and security on Microsoft Azure and Amazon Web Services to help your business scale without limits.

More info

Cybersecurity and pentesting

Security audits, penetration testing and protection of applications, data and infrastructure on-premise and cloud, with ethical hacking and regulatory compliance.

More info

Business Intelligence

Dashboards and data analysis with Power BI: we integrate your sources, design dashboards and KPIs and turn your data into decisions.

More info

Process automation

We automate repetitive tasks and connect your applications with n8n, Power Automate, Make, and RPA, eliminating manual work and increasing productivity.

More info

Training for Companies

We train your teams in technology with criteria: web development, databases, Git, best practices and security, automation with n8n, artificial intelligence for companies and creation of AI solutions with Azure AI Foundry.

More info

Code Auditing

We audit the code that you, your team or an AI create: we tell you what is good and what to improve, we secure it and make it ready for production, web or app.

More info

AI Image Generation

We create for you the images that your business needs with artificial intelligence: product, networks, advertising, illustration and avatars. You tell us what you want and we deliver it ready to use.

More info

AI Video Generation

We create videos with artificial intelligence for you: promotional, networking, virtual presenters, dubbing and animations. You tell us the idea and we will deliver it assembled and ready to publish.

More info

AI Conversational Avatars

We create conversational avatars with AI – digital humans with a face and voice – that serve your customers and teams with the knowledge of your company, on your website, interactive monitors, WhatsApp or Teams.

More info

Online Marketing and AI

Google Ads, Meta Ads, LinkedIn Ads and AI Engine Positioning (GEO/AEO): we attract customers and make your brand appear where they search for you, also on ChatGPT, Gemini and Perplexity.

More info

Do you have a project in mind?

Tell us your vision and we'll turn it into a software solution. Whatever the scope, we make your idea real.

Live Chat