Browse Source

fix: wildcard certificate challenge method not present

Jacky 1 year ago
parent
commit
97ec26331b

+ 2 - 0
api/certificate/issue.go

@@ -123,6 +123,8 @@ func IssueCert(c *gin.Context) {
 		SSLCertificateKeyPath: sslCertificateKeyPath,
 		AutoCert:              model.AutoCertEnabled,
 		KeyType:               payload.KeyType,
+		ChallengeMethod:       payload.ChallengeMethod,
+		DnsCredentialID:       payload.DNSCredentialID,
 	})
 
 	if err != nil {

+ 41 - 1
app/src/views/certificate/WildcardCertificate.vue

@@ -23,6 +23,7 @@ function open() {
   step.value = 0
   data.value = {
     challenge_method: 'dns01',
+    key_type: '2048',
   } as Cert
 }
 
@@ -45,12 +46,39 @@ const issueCert = () => {
   modalVisible.value = true
 
   refObtainCertLive.value.issue_cert(computedDomain.value,
-    [computedDomain.value, domain.value])
+    [computedDomain.value, domain.value], data.value.key_type)
     .then(() => {
       message.success($gettext('Renew successfully'))
       emit('issued')
     })
 }
+
+const keyType = shallowRef([
+  {
+    key: '2048',
+    name: 'RSA2048',
+  },
+  {
+    key: '3072',
+    name: 'RSA3072',
+  },
+  {
+    key: '4096',
+    name: 'RSA4096',
+  },
+  {
+    key: '8192',
+    name: 'RAS8192',
+  },
+  {
+    key: 'P256',
+    name: 'EC256',
+  },
+  {
+    key: 'P384',
+    name: 'EC384',
+  },
+])
 </script>
 
 <template>
@@ -75,6 +103,18 @@ const issueCert = () => {
               addon-before="*."
             />
           </AFormItem>
+
+          <AFormItem :label="$gettext('Key Type')">
+            <ASelect v-model:value="data.key_type">
+              <ASelectOption
+                v-for="t in keyType"
+                :key="t.key"
+                :value="t.key"
+              >
+                {{ t.name }}
+              </ASelectOption>
+            </ASelect>
+          </AFormItem>
         </AForm>
         <div
           v-if="step === 0"

+ 2 - 2
app/src/views/domain/cert/components/AutoCertStepOne.vue

@@ -44,8 +44,8 @@ const keyType = shallowRef([
 ])
 
 onMounted(() => {
-  if (data.value.key_type === '')
-    data.value.key_type = 'RSA2048'
+  if (!data.value.key_type)
+    data.value.key_type = '2048'
 })
 </script>
 

+ 1 - 1
internal/validation/key_type.go

@@ -7,7 +7,7 @@ import (
 
 func autoCertKeyType(fl val.FieldLevel) bool {
 	switch certcrypto.KeyType(fl.Field().String()) {
-	case certcrypto.RSA2048, certcrypto.RSA3072, certcrypto.RSA4096,
+	case "", certcrypto.RSA2048, certcrypto.RSA3072, certcrypto.RSA4096,
 		certcrypto.EC256, certcrypto.EC384:
 		return true
 	}