Skip to content

Commit 4ade15b

Browse files
committed
feat(CSR Generator): allows RSA Bits
Fix #339
1 parent 3c58f7c commit 4ade15b

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

locales/en.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,6 +1525,8 @@ tools:
15251525
tag-certificate-signing-request: Certificate Signing Request
15261526
tag-public-key: Public key
15271527
tag-private-key: Private key
1528+
label-rsa-bits: 'RSA Bits:'
1529+
bits-should-be-256-less-than-bits-less-than-16384-and-be-a-multiple-of-8: Bits should be 256 <= bits <= 16384 and be a multiple of 8
15281530
css-prettifier:
15291531
title: Css prettifier
15301532
description: CSS Prettify

src/tools/csr-generator/csr-generator.vue

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import TextareaCopyable from '@/components/TextareaCopyable.vue';
55
import { withDefaultOnErrorAsync } from '@/utils/defaults';
66
import { computedRefreshableAsync } from '@/composable/computedRefreshable';
77
import { useValidation } from '@/composable/validation';
8-
import { useQueryParam } from '@/composable/queryParams';
8+
import { useQueryParam, useQueryParamOrStorage } from '@/composable/queryParams';
99
1010
const { t } = useI18n();
1111
@@ -23,13 +23,24 @@ const commonNameValidation = useValidation({
2323
const organizationName = useQueryParam({ tool: 'csr-gen', name: 'org', defaultValue: 'Test' });
2424
const organizationalUnit = useQueryParam({ tool: 'csr-gen', name: 'ou', defaultValue: '' });
2525
const password = ref('');
26+
const bits = useQueryParamOrStorage({ name: 'bits', storageName: 'csr-gen:b', defaultValue: 2048 });
2627
const city = useQueryParam({ tool: 'csr-gen', name: 'city', defaultValue: 'Paris' });
2728
const state = useQueryParam({ tool: 'csr-gen', name: 'state', defaultValue: 'FR' });
2829
const country = useQueryParam({ tool: 'csr-gen', name: 'country', defaultValue: 'France' });
2930
const contactEmail = useQueryParam({ tool: 'csr-gen', name: 'email', defaultValue: '' });
3031
const subjectAlternativeNames = ref('');
3132
const 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+
3344
const [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

Comments
 (0)