Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Citrix Node): add certificate install operation #4308

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
149 changes: 148 additions & 1 deletion packages/nodes-base/nodes/Citrix/ADC/CertificateDescription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ export const certificateDescription: INodeProperties[] = [
value: 'create',
action: 'Create a certificate',
},
{
name: 'Install',
value: 'install',
action: 'Install a certificate',
},
],
default: 'create',
displayOptions: {
Expand All @@ -20,6 +25,9 @@ export const certificateDescription: INodeProperties[] = [
},
},
},
/* -------------------------------------------------------------------------- */
/* certificate:create */
/* -------------------------------------------------------------------------- */
{
displayName: 'Certificate File Name',
name: 'certificateFileName',
Expand Down Expand Up @@ -221,7 +229,8 @@ export const certificateDescription: INodeProperties[] = [
},
},
default: '',
description: 'Serial number file maintained for the CA certificate. This file contains the serial number of the next certificate to be issued or signed by the CA.',
description:
'Serial number file maintained for the CA certificate. This file contains the serial number of the next certificate to be issued or signed by the CA.',
},
{
displayName: 'Private Key Format',
Expand Down Expand Up @@ -305,4 +314,142 @@ export const certificateDescription: INodeProperties[] = [
},
],
},
/* -------------------------------------------------------------------------- */
/* certificate:install */
/* -------------------------------------------------------------------------- */
{
displayName: 'Certificate-Key Pair Name',
name: 'certificateKeyPairName',
type: 'string',
required: true,
displayOptions: {
show: {
resource: ['certificate'],
operation: ['install'],
},
},
default: '',
description: 'Name for the certificate and private-key pair',
},
{
displayName: 'Certificate File Name',
name: 'certificateFileName',
type: 'string',
required: true,
displayOptions: {
show: {
resource: ['certificate'],
operation: ['install'],
},
},
default: '',
description: 'Name of and, optionally, path to the X509 certificate file that is used to form the certificate-key pair. /nsconfig/ssl/ is the default path.',
},
{
displayName: 'Private Key File Name',
name: 'privateKeyFileName',
type: 'string',
default: '',
required: true,
displayOptions: {
show: {
resource: ['certificate'],
operation: ['install'],
},
},
description: 'Name of and, optionally, path to the X509 certificate file that is used to form the certificate-key pair. /nsconfig/ssl/ is the default path.',
},
{
displayName: 'Certificate Format',
name: 'certificateFormat',
type: 'options',
options: [
{
name: 'PEM',
value: 'PEM',
},
{
name: 'DER',
value: 'DER',
},
],
required: true,
displayOptions: {
show: {
resource: ['certificate'],
operation: ['install'],
},
},
default: 'PEM',
description:
'Input format of the certificate and the private-key files. The three formats supported by the appliance are: PEM - Privacy Enhanced Mail DER - Distinguished Encoding Rule PFX - Personal Information Exchange.',
},
{
displayName: 'Password',
name: 'password',
type: 'string',
typeOptions: {
password: true,
},
required: true,
displayOptions: {
show: {
resource: ['certificate'],
operation: ['install'],
certificateFormat: ['PEM'],
},
},
default: '',
description:
'Input format of the certificate and the private-key files. The three formats supported by the appliance are: PEM - Privacy Enhanced Mail DER - Distinguished Encoding Rule PFX - Personal Information Exchange.',
},
{
displayName: 'Notify When Expires',
name: 'notifyExpiration',
type: 'boolean',
required: true,
displayOptions: {
show: {
resource: ['certificate'],
operation: ['install'],
},
},
default: false,
description: 'Whether to alert when the certificate is about to expire',
},
{
displayName: 'Notification Period (Days)',
name: 'notificationPeriod',
type: 'number',
default: 10,
required: true,
typeOptions: {
minValue: 10,
maxValue: 100,
},
displayOptions: {
show: {
resource: ['certificate'],
operation: ['install'],
notifyExpiration: [true],
},
},
description:
'Time, in number of days, before certificate expiration, at which to generate an alert that the certificate is about to expire',
},
{
displayName: 'Certificate Bundle',
name: 'certificateBundle',
type: 'boolean',
default: false,
displayOptions: {
show: {
resource: ['certificate'],
operation: ['install'],
certificateFormat: ['PEM'],
},
},
description:
"Whether to parse the certificate chain as a single file after linking the server certificate to its issuer's certificate within the file",
},
];
61 changes: 56 additions & 5 deletions packages/nodes-base/nodes/Citrix/ADC/CitrixAdc.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,23 @@ export class CitrixAdc implements INodeType {
...body,
keyfile: privateKeyFileName,
};

} else {
const caCertificateFileName = this.getNodeParameter('caCertificateFileName', i) as string;
const caCertificateFileFormat = this.getNodeParameter('caCertificateFileFormat', i) as string;
const caPrivateKeyFileFormat = this.getNodeParameter('caPrivateKeyFileFormat', i) as string;
const caPrivateKeyFileName = this.getNodeParameter('caPrivateKeyFileName', i) as string;
const caCertificateFileName = this.getNodeParameter(
'caCertificateFileName',
i,
) as string;
const caCertificateFileFormat = this.getNodeParameter(
'caCertificateFileFormat',
i,
) as string;
const caPrivateKeyFileFormat = this.getNodeParameter(
'caPrivateKeyFileFormat',
i,
) as string;
const caPrivateKeyFileName = this.getNodeParameter(
'caPrivateKeyFileName',
i,
) as string;
const caSerialFileNumber = this.getNodeParameter('caSerialFileNumber', i) as string;

body = {
Expand All @@ -196,6 +207,46 @@ export class CitrixAdc implements INodeType {

responseData = { success: true };
}

if (operation === 'install') {
const certificateKeyPairName = this.getNodeParameter(
'certificateKeyPairName',
i,
) as string;
const certificateFileName = this.getNodeParameter('certificateFileName', i) as string;
const privateKeyFileName = this.getNodeParameter('privateKeyFileName', i) as string;
const certificateFormat = this.getNodeParameter('certificateFormat', i) as string;
const notifyExpiration = this.getNodeParameter('notifyExpiration', i) as boolean;
const body: IDataObject = {
cert: certificateFileName,
certkey: certificateKeyPairName,
key: privateKeyFileName,
inform: certificateFormat,
};

if (certificateFormat === 'PEM') {
const password = this.getNodeParameter('password', i) as string;
const certificateBundle = this.getNodeParameter('certificateBundle', i) as boolean;
Object.assign(body, {
passplain: password,
bundle: certificateBundle ? 'YES' : 'NO',
});
}

if (notifyExpiration) {
const notificationPeriod = this.getNodeParameter('notificationPeriod', i) as number;
Object.assign(body, {
expirymonitor: 'ENABLED',
notificationperiod: notificationPeriod,
});
}

const endpoint = `/config/sslcertkey`;

await citrixADCApiRequest.call(this, 'POST', endpoint, { sslcertkey: body });

responseData = { success: true };
}
}

returnData.push(
Expand Down