AutoCertStepOne.vue 4.0 KB

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