Skip to content

Commit 2f37dfb

Browse files
committed
remove FQDN check which utilized node-forge package - removed node-forge package
1 parent 5286259 commit 2f37dfb

File tree

2 files changed

+0
-28
lines changed

2 files changed

+0
-28
lines changed

packages/forklift-console-plugin/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
"jsonpath": "^1.1.1",
4242
"jsrsasign": "11.1.0",
4343
"luxon": "^3.5.0",
44-
"node-forge": "^1",
4544
"react": "17.0.2",
4645
"react-dom": "17.0.2",
4746
"react-i18next": "^11.14.3",

packages/forklift-console-plugin/src/modules/Providers/utils/validators/provider/vsphere/validateVCenterURL.ts

-27
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,8 @@
1-
import { pki } from 'node-forge';
2-
31
import { IoK8sApiCoreV1Secret } from '@kubev2v/types';
42

53
import { safeBase64Decode } from '../../../helpers';
64
import { validateIpv4, validateURL, ValidationMsg } from '../../common';
75

8-
export const urlMatchesCertFqdn = (urlHostname: string, caCert: string): boolean => {
9-
try {
10-
const decodedCaCert = safeBase64Decode(caCert);
11-
const cert = pki.certificateFromPem(decodedCaCert);
12-
const dnsAltName = cert.extensions
13-
.find((ext) => ext.name === 'subjectAltName')
14-
?.altNames.find((altName) => altName.type === 2)?.value;
15-
const commonName = cert.subject.attributes.find((attr) => attr.name === 'commonName')?.value;
16-
17-
return urlHostname === commonName || urlHostname === dnsAltName;
18-
} catch (e) {
19-
console.error('Unable to parse certificate object from PEM.');
20-
}
21-
22-
return false;
23-
};
24-
256
export const validateVCenterURL = (url: string, secret?: IoK8sApiCoreV1Secret): ValidationMsg => {
267
// For a newly opened form where the field is not set yet, set the validation type to default.
278
if (url === undefined) {
@@ -58,16 +39,8 @@ export const validateVCenterURL = (url: string, secret?: IoK8sApiCoreV1Secret):
5839
}
5940

6041
if (isSecure) {
61-
const caCert = secret?.data?.cacert;
6242
const isValidIpAddress = validateIpv4(urlHostname);
6343

64-
if (!isValidIpAddress && caCert && !urlMatchesCertFqdn(urlHostname, caCert)) {
65-
return {
66-
type: 'error',
67-
msg: 'Invalid URL. The URL must be a fully qualified domain name (FQDN) and match the FQDN in the certificate you uploaded.',
68-
};
69-
}
70-
7144
if (isValidIpAddress) {
7245
return {
7346
type: 'warning',

0 commit comments

Comments
 (0)