Herramientas GitHub Pages

Gratis Generador de claves VAPID

Genera un par de claves VAPID para notificaciones Web Push usando la API Web Crypto.

Cargando herramienta...

Qué es Generador de claves VAPID?

VAPID (Voluntary Application Server Identification) is part of the Web Push Protocol. It uses a public/private key pair to identify your application server to push services (like Google's FCM or Mozilla's autopush). The public key is sent to the browser during push subscription. The private key stays on your server and signs push messages. Together they prove the push message comes from your server and not an impersonator.

Respuesta rápida

Generate a VAPID key pair for Web Push notifications. The public key goes in your frontend JavaScript for pushManager.subscribe(). The private key stays on your server and is used with the web-push library or Firebase to sign push messages. Never expose the private key.

Limitaciones

  • Keys generated in the browser are only as secure as the browser environment. For production use, consider generating keys server-side with OpenSSL and storing the private key in a secure secrets manager.
  • The Web Crypto API requires a secure context (HTTPS or localhost). If the browser does not support Web Crypto, the tool cannot generate keys.
  • VAPID keys use the P-256 (prime256v1) curve. Some older push libraries expect different formats — always verify the format expected by your specific push service or library.

Cómo usar esta herramienta

  1. Click the Generate Key Pair button to create a new P-256 key pair using your browser's Web Crypto API.
  2. Copy the public key into your frontend JavaScript where you call pushManager.subscribe().
  3. Copy the private key into your server environment variables and use it with the web-push library or Firebase.
  4. Never expose the private key — it stays on your server and is used to sign push messages.

Para qué puedes usarla

  • Generate a VAPID key pair for adding web push notifications to a web app.
  • Replace an accidentally exposed VAPID key pair with a fresh one.
  • Set up push notifications with the web-push npm library, Firebase Cloud Messaging, or a custom push server.

Casos de uso

Ejemplos prácticos

Ejemplo

Set up web-push on a Node.js server

Generate a key pair. Store the private key in an environment variable. Use the public key in the frontend to subscribe users. On the server, use webpush.setVapidDetails() with both keys and a mailto: contact URL.

Ejemplo

Configure Firebase Cloud Messaging for Web Push

Generate a key pair. In the Firebase Console > Project Settings > Cloud Messaging, upload the key pair under Web Push certificates. Use the public key in your Firebase web app initialization.

Errores comunes

  • Committing the private key to a public git repository — the private key must be kept secret and managed through environment variables or a secrets manager.
  • Using the same VAPID key pair for multiple unrelated applications — generate a separate key pair for each application for better security isolation.
  • Losing the private key — there is no way to recover a VAPID private key. You must generate a new pair and update both the server and all subscribed clients.

Verificación

  1. Test the key pair by subscribing a browser to push notifications and sending a test push message from your server.
  2. Verify the public key is correctly embedded in your frontend JavaScript by checking the applicationServerKey parameter in the pushManager.subscribe() call.

FAQ

Preguntas sobre Generador de claves VAPID

Can I generate the VAPID keys on my server instead?

Yes, and for production use that is recommended. Use OpenSSL: openssl ecparam -genkey -name prime256v1 -noout -out vapid_private.pem && openssl ec -in vapid_private.pem -pubout -out vapid_public.pem. This browser tool is convenient for development, testing, and quick setup.

What happens if my VAPID private key is exposed?

Anyone with the private key can send push messages that appear to come from your server. Generate a new key pair immediately, update your server with the new keys, and resubscribe all your push users with the new public key. Push subscriptions are tied to the public key — old subscriptions cannot receive messages signed with a new key.

Do I need a VAPID key pair for Firebase Cloud Messaging?

Yes, if you are using the Web Push Protocol with FCM. Firebase requires a VAPID key pair under Project Settings > Cloud Messaging > Web Push certificates. This is separate from the Firebase server key and is required for web push notifications to work with FCM as a push service.

Herramientas relacionadas

Más herramientas github pages

Prueba también

Prueba también