| 12345678910111213141516171819202122232425 |
- 'use strict';
- const { calculatePartialFingerprintOfEscapedPemCertificate } = require('../../modules/certificate');
- module.exports = async (req, res, next) => {
- if (req.headers['ssl_client_s_dn_cn'] && req.headers['ssl_client_s_dn_cn'] !== 'no_client_cert') {
- req.clientCertificateCn = req.headers['ssl_client_s_dn_cn'];
- } else {
- const err = new Error('Unauthorized');
- err.status = 403;
- return next(err);
- }
- if (req.headers['ssl_client_certificate']) {
- const pemCertificateEscaped = req.headers['ssl_client_certificate'];
- const fingerprint = calculatePartialFingerprintOfEscapedPemCertificate(pemCertificateEscaped);
- req.clientCertificateFingerprint = fingerprint;
- } else {
- const err = new Error('Unauthorized');
- err.status = 403;
- return next(err);
- }
- return next();
- };
|