createCertificate.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.createCertificate = void 0;
  4. // https://github.com/webpack/webpack-dev-server/blob/master/lib/utils/createCertificate.js
  5. function createCertificate() {
  6. const pems = require('selfsigned').generate(null, {
  7. algorithm: 'sha256',
  8. days: 30,
  9. keySize: 2048,
  10. extensions: [
  11. // {
  12. // name: 'basicConstraints',
  13. // cA: true,
  14. // },
  15. {
  16. name: 'keyUsage',
  17. keyCertSign: true,
  18. digitalSignature: true,
  19. nonRepudiation: true,
  20. keyEncipherment: true,
  21. dataEncipherment: true
  22. },
  23. {
  24. name: 'extKeyUsage',
  25. serverAuth: true,
  26. clientAuth: true,
  27. codeSigning: true,
  28. timeStamping: true
  29. },
  30. {
  31. name: 'subjectAltName',
  32. altNames: [
  33. {
  34. // type 2 is DNS
  35. type: 2,
  36. value: 'localhost'
  37. },
  38. {
  39. type: 2,
  40. value: 'localhost.localdomain'
  41. },
  42. {
  43. type: 2,
  44. value: 'lvh.me'
  45. },
  46. {
  47. type: 2,
  48. value: '*.lvh.me'
  49. },
  50. {
  51. type: 2,
  52. value: '[::1]'
  53. },
  54. {
  55. // type 7 is IP
  56. type: 7,
  57. ip: '127.0.0.1'
  58. },
  59. {
  60. type: 7,
  61. ip: 'fe80::1'
  62. }
  63. ]
  64. }
  65. ]
  66. });
  67. return pems.private + pems.cert;
  68. }
  69. exports.createCertificate = createCertificate;
  70. //# sourceMappingURL=createCertificate.js.map