I have a simple NestJS controller that looks like this:
@Patch('/tenantMappings/:tenantId')
@HttpCode(HttpStatus.OK)
async tenantMappings(
@Param('tenantId') tenantId,
@Body() request: RequestDto,
) {
try {
this.logger.log(
'Provider App: Received TenantMapping Request with payload: ',
request,
);
return await this.tenantMappingService.createTenantMapping(
request
);
} catch (error) {
this.logger.error(
'Provider App: Error while handling tenant mapping: ',
error.message,
);
return;
}
}
This is being called a cloud application using mTLS certificates. I would need to extract the certificate and verify that the issuer and subjectname match a given pattern.
Is there a way we can do this in NestJs?
In the Spring Boot (Java) stack. this is one way of doing this.
public X509Certificate extractClientCertificate(HttpServletRequest request) {
X509Certificate[] certs = (X509Certificate[]) request.getAttribute(JAVAX_SERVLET_REQUEST_X509_CERTIFICATE);
}