@@ -5,7 +5,7 @@ import TextareaCopyable from '@/components/TextareaCopyable.vue';
55import { withDefaultOnErrorAsync } from ' @/utils/defaults' ;
66import { computedRefreshableAsync } from ' @/composable/computedRefreshable' ;
77import { useValidation } from ' @/composable/validation' ;
8- import { useQueryParam } from ' @/composable/queryParams' ;
8+ import { useQueryParam , useQueryParamOrStorage } from ' @/composable/queryParams' ;
99
1010const { t } = useI18n ();
1111
@@ -23,13 +23,24 @@ const commonNameValidation = useValidation({
2323const organizationName = useQueryParam ({ tool: ' csr-gen' , name: ' org' , defaultValue: ' Test' });
2424const organizationalUnit = useQueryParam ({ tool: ' csr-gen' , name: ' ou' , defaultValue: ' ' });
2525const password = ref (' ' );
26+ const bits = useQueryParamOrStorage ({ name: ' bits' , storageName: ' csr-gen:b' , defaultValue: 2048 });
2627const city = useQueryParam ({ tool: ' csr-gen' , name: ' city' , defaultValue: ' Paris' });
2728const state = useQueryParam ({ tool: ' csr-gen' , name: ' state' , defaultValue: ' FR' });
2829const country = useQueryParam ({ tool: ' csr-gen' , name: ' country' , defaultValue: ' France' });
2930const contactEmail = useQueryParam ({ tool: ' csr-gen' , name: ' email' , defaultValue: ' ' });
3031const subjectAlternativeNames = ref (' ' );
3132const emptyCSR = { csrPem: ' ' , privateKeyPem: ' ' , publicKeyPem: ' ' };
3233
34+ const { attrs : bitsValidationAttrs } = useValidation ({
35+ source: bits ,
36+ rules: [
37+ {
38+ message: t (' tools.csr-generator.texts.bits-should-be-256-less-than-bits-less-than-16384-and-be-a-multiple-of-8' ),
39+ validator : value => value >= 256 && value <= 16384 && value % 8 === 0 ,
40+ },
41+ ],
42+ });
43+
3344const [certs, refreshCerts] = computedRefreshableAsync (
3445 () => withDefaultOnErrorAsync (() => {
3546 if (! commonNameValidation .isValid ) {
@@ -38,6 +49,7 @@ const [certs, refreshCerts] = computedRefreshableAsync(
3849
3950 return generateCSR ({
4051 password: password .value ,
52+ bits: bits .value ,
4153 commonName: commonName .value ,
4254 countryName: country .value ,
4355 city: city .value ,
@@ -167,6 +179,12 @@ const [certs, refreshCerts] = computedRefreshableAsync(
167179 </n-form-item >
168180 </div >
169181
182+ <div >
183+ <n-form-item :label =" t('tools.csr-generator.texts.label-rsa-bits')" v-bind =" bitsValidationAttrs as any" label-placement =" left" >
184+ <n-input-number-i18n v-model:value =" bits" min =" 256" max =" 16384" step =" 8" />
185+ </n-form-item >
186+ </div >
187+
170188 <div flex justify-center >
171189 <c-button @click =" refreshCerts" >
172190 {{ t('tools.csr-generator.texts.tag-refresh-csr') }}
0 commit comments