AutoCertStepOne.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <script setup lang="ts">
  2. import { $gettext } from '../../../../gettext'
  3. import type { AutoCertOptions } from '@/api/auto_cert'
  4. import DNSChallenge from '@/views/site/cert/components/DNSChallenge.vue'
  5. import ACMEUserSelector from '@/views/certificate/ACMEUserSelector.vue'
  6. import { PrivateKeyTypeList } from '@/constants'
  7. const props = defineProps<{
  8. hideNote?: boolean
  9. forceDnsChallenge?: boolean
  10. }>()
  11. const data = defineModel<AutoCertOptions>('options', {
  12. default: () => {
  13. return {}
  14. },
  15. required: true,
  16. })
  17. onMounted(() => {
  18. if (!data.value.key_type)
  19. data.value.key_type = '2048'
  20. if (props.forceDnsChallenge)
  21. data.value.challenge_method = 'dns01'
  22. })
  23. watch(() => props.forceDnsChallenge, v => {
  24. if (v)
  25. data.value.challenge_method = 'dns01'
  26. })
  27. </script>
  28. <template>
  29. <div>
  30. <AAlert
  31. v-if="!hideNote"
  32. type="info"
  33. show-icon
  34. :message="$gettext('Note')"
  35. class="mb-4"
  36. >
  37. <template #description>
  38. <p>
  39. {{ $gettext('The server_name'
  40. + ' in the current configuration must be the domain name you need to get the certificate, support'
  41. + 'multiple domains.') }}
  42. </p>
  43. <p>
  44. {{ $gettext('The certificate for the domain will be checked 30 minutes, '
  45. + 'and will be renewed if it has been more than 1 week or the period you set in settings since it was last issued.') }}
  46. </p>
  47. <p v-if="data.challenge_method === 'http01'">
  48. {{ $gettext('Make sure you have configured a reverse proxy for .well-known '
  49. + 'directory to HTTPChallengePort before obtaining the certificate.') }}
  50. </p>
  51. <p v-else-if="data.challenge_method === 'dns01'">
  52. {{ $gettext('Please first add credentials in Certification > DNS Credentials, '
  53. + 'and then select one of the credentials'
  54. + 'below to request the API of the DNS provider.') }}
  55. </p>
  56. </template>
  57. </AAlert>
  58. <AForm layout="vertical">
  59. <AFormItem
  60. v-if="!forceDnsChallenge"
  61. :label="$gettext('Challenge Method')"
  62. >
  63. <ASelect v-model:value="data.challenge_method">
  64. <ASelectOption value="http01">
  65. {{ $gettext('HTTP01') }}
  66. </ASelectOption>
  67. <ASelectOption value="dns01">
  68. {{ $gettext('DNS01') }}
  69. </ASelectOption>
  70. </ASelect>
  71. </AFormItem>
  72. <AFormItem :label="$gettext('Key Type')">
  73. <ASelect v-model:value="data.key_type">
  74. <ASelectOption
  75. v-for="t in PrivateKeyTypeList"
  76. :key="t.key"
  77. :value="t.key"
  78. >
  79. {{ t.name }}
  80. </ASelectOption>
  81. </ASelect>
  82. </AFormItem>
  83. </AForm>
  84. <ACMEUserSelector v-model:options="data" />
  85. <DNSChallenge
  86. v-if="data.challenge_method === 'dns01'"
  87. v-model:options="data"
  88. />
  89. <AForm layout="vertical">
  90. <AFormItem :label="$gettext('OCSP Must Staple')">
  91. <template #help>
  92. <p>
  93. {{ $gettext('Do not enable this option unless you are sure that you need it.') }}
  94. {{ $gettext('OCSP Must Staple may cause errors for some users on first access using Firefox.') }}
  95. <a href="https://github.com/0xJacky/nginx-ui/issues/322">#322</a>
  96. </p>
  97. </template>
  98. <ASwitch v-model:checked="data.must_staple" />
  99. </AFormItem>
  100. <AFormItem :label="$gettext('Lego disable CNAME Support')">
  101. <template #help>
  102. <p>
  103. {{ $gettext('If your domain has CNAME records and you cannot obtain certificates, '
  104. + 'you need to enable this option.') }}
  105. </p>
  106. </template>
  107. <ASwitch v-model:checked="data.lego_disable_cname_support" />
  108. </AFormItem>
  109. </AForm>
  110. </div>
  111. </template>
  112. <style lang="less" scoped>
  113. </style>