BewareMyPower commented on code in PR #301: URL: https://github.com/apache/pulsar-client-node/pull/301#discussion_r1116787312
########## src/Client.js: ########## @@ -0,0 +1,65 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +const tls = require('tls'); +const fs = require('fs'); +const os = require('os'); +const PulsarBinding = require('./pulsar-binding'); + +const tmpCertsFilePath = `${__dirname}/cert.pem`; + +class Client { + constructor(params) { + if (typeof params.tlsTrustCertsFilePath === 'undefined') { + fs.rmSync(tmpCertsFilePath, { force: true }); + const fd = fs.openSync(tmpCertsFilePath, 'a'); + try { + tls.rootCertificates.forEach((cert) => { + fs.appendFileSync(fd, cert + os.EOL); + }); + } finally { + fs.closeSync(fd); + } Review Comment: Here is an example: https://www.npmjs.com/package/node_extra_ca_certs_mozilla_bundle?activeTab=explore It writes the pem files during `npm install`. You can see the effect that: ```bash $ npm install node_extra_ca_certs_mozilla_bundle added 8 packages in 18s 63 packages are looking for funding run `npm fund` for details $ ls node_modules/node_extra_ca_certs_mozilla_bundle/ca_bundle ca_intermediate_bundle.pem ca_intermediate_root_bundle.pem ca_root_bundle.pem ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
