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

Improve certificate logging #254

Open
wants to merge 8 commits into
base: v1.x/staging
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
All notable changes to the Zlux Server Framework package will be documented in this file.
This repo is part of the app-server Zowe Component, and the change logs here may appear on Zowe.org in that section.

## 1.17.0
- Enhancement: Verbose logging of certificate and CA certificate details when logLevel=3 (FINE)

## 1.16.0

- [D] Feature: Expose GET /server/environment endpoint with minimal data when RBAC is off, to share only environment details that are required to do dependency checks and more accurate server-to-server communication (#237)
Expand Down
23 changes: 23 additions & 0 deletions lib/webserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ function loadPem(locations, type, keyrings) {
function readTlsOptionsFromConfig(config, httpsOptions) {
//in case keys and certs can be read from the same keyring, store them here for later retrieval
let keyrings = {};
let forge = require('node-forge');
if (config.https.pfx) {
try {
httpsOptions.pfx = fs.readFileSync(config.https.pfx);
Expand All @@ -188,6 +189,17 @@ function readTlsOptionsFromConfig(config, httpsOptions) {
} else {
if (config.https.certificates) {
httpsOptions.cert = loadPem(config.https.certificates, CRYPTO_CONTENT_CERT, keyrings).content;
for(let i = 0; i < httpsOptions.cert.length; i++){
let curCert = forge.pki.certificateFromPem(httpsOptions.cert[i]);
let certData = {
signature: curCert.signature,
validity: curCert.validity,
issuer: curCert.issuer,
extensions: curCert.extensions,
publicKey: curCert.publicKey,
}
networkLogger.debug(`ZWED0072I`, JSON.stringify(certData, null, 2));
}
bootstrapLogger.info('ZWED0072I', config.https.certificates); //bootstrapLogger.info('Using Certificate: ' + config.https.certificates);
}
if (config.https.keys) {
Expand All @@ -196,6 +208,17 @@ function readTlsOptionsFromConfig(config, httpsOptions) {
}
if (config.https.certificateAuthorities) {
httpsOptions.ca = loadPem(config.https.certificateAuthorities, CRYPTO_CONTENT_CA, keyrings).content;
for(let i = 0; i < httpsOptions.ca.length; i++){
let curCert = forge.pki.certificateFromPem(httpsOptions.ca[i]);
let certData = {
signature: curCert.signature,
validity: curCert.validity,
issuer: curCert.issuer,
extensions: curCert.extensions,
publicKey: curCert.publicKey,
}
networkLogger.debug(`ZWED0072I`, JSON.stringify(certData, null, 2));
}
}
if (config.https.certificateRevocationLists) {
httpsOptions.crl = loadPem(config.https.certificateRevocationLists, CRYPTO_CONTENT_CRL, keyrings).content;
Expand Down