Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const forge = require('node-forge');
const pki = forge.pki;
const fs = require('fs');
const path = require('path');
const mkdirp = require('mkdirp');
// CNanme
var domain = 'github.com';
var caCertPem = fs.readFileSync(path.join(__dirname, '../../rootCA/rootCA.crt'));
var caKeyPem = fs.readFileSync(path.join(__dirname, '../../rootCA/rootCA.key.pem'));
var caCert = forge.pki.certificateFromPem(caCertPem);
var caKey = forge.pki.privateKeyFromPem(caKeyPem);
var keys = pki.rsa.generateKeyPair(1024);
var cert = pki.createCertificate();
cert.publicKey = keys.publicKey;
cert.serialNumber = (new Date()).getTime() + '';
cert.validity.notBefore = new Date();
cert.validity.notBefore.setFullYear(cert.validity.notBefore.getFullYear() - 1);
cert.validity.notAfter = new Date();
cert.validity.notAfter.setFullYear(cert.validity.notAfter.getFullYear() + 1);
var attrs = [{
name: 'commonName',
value: domain
}, {
name: 'countryName',
const forge = require('node-forge');
const pki = forge.pki;
const fs = require('fs');
const path = require('path');
const mkdirp = require('mkdirp');
// CNanme
var domain = 'github.com';
var caCertPem = fs.readFileSync(path.join(__dirname, '../../rootCA/rootCA.crt'));
var caKeyPem = fs.readFileSync(path.join(__dirname, '../../rootCA/rootCA.key.pem'));
var caCert = forge.pki.certificateFromPem(caCertPem);
var caKey = forge.pki.privateKeyFromPem(caKeyPem);
var keys = pki.rsa.generateKeyPair(1024);
var cert = pki.createCertificate();
cert.publicKey = keys.publicKey;
var webid = require('webid')
var $rdf = require('rdflib')
var sym = $rdf.sym
var lit = $rdf.lit
var async = require('async')
var parallel = async.parallel
var debug = require('./../debug').idp
var express = require('express')
var bodyParser = require('body-parser')
var errorHandler = require('./../handlers/error-pages')
var url = require('url')
var uriAbs = require('./../utils').uriAbs
var serialize = require('./../utils').serialize
var forge = require('node-forge')
var asn1 = forge.asn1
var pki = forge.pki
var parse = require('./../utils').parse
var stringToStream = require('./../utils').stringToStream
const stripLineEndings = require('./../utils').stripLineEndings
var defaultContainers = []
function defaultBuildURI (account, host, port) {
var hostAndPort = (host || 'localhost') + (port || '')
return 'https://' + hostAndPort + '/'
}
// IdentityProvider singleton
function IdentityProvider (options) {
options = options || {}
this.store = options.store
this.pathCard = options.pathCard || 'profile/card'
const forge = require('node-forge');
const pki = forge.pki;
const fs = require('fs');
const path = require('path');
const mkdirp = require('mkdirp');
// CNanme
var domain = 'github.com';
var caCertPem = fs.readFileSync(path.join(__dirname, './rootCA/rootCA.crt'));
var caKeyPem = fs.readFileSync(path.join(__dirname, './rootCA/rootCA.key.pem'));
var caCert = forge.pki.certificateFromPem(caCertPem);
var caKey = forge.pki.privateKeyFromPem(caKeyPem);
var keys = pki.rsa.generateKeyPair(1024);
var cert = pki.createCertificate();
cert.publicKey = keys.publicKey;
function generateKeyPair() {
const rsa = forge.pki.rsa;
console.log('Generating keys. It might take a few seconds!');
return rsa.generateKeyPair({ bits: 2048, e: 0x10001 });
}
var KeyCred = function(certparams) {
var keys = forge.pki.rsa.generateKeyPair(2048);
this.publicKey = keys.publicKey;
this.privateKey = keys.privateKey;
this.cert = this.createCertificate(certparams);
this.keycred = null;
this.digest = null;
};
setPrivateKey(signerKeyMessage: string, password?: string): void {
this.key = forge.pki.decryptRsaPrivateKey(signerKeyMessage, password);
if (!this.key)
throw new Error(
'Failed to decode provided private key. Invalid password?',
);
}
private publicKeyToPkcs1Data(pkcs8PublicKey: ArrayBuffer): NSData {
const pkcs8ByteString = String.fromCharCode.apply(null, new Uint8Array(pkcs8PublicKey));
const asn1 = forge.asn1.fromDer(pkcs8ByteString);
const publicKey = forge.pki.publicKeyFromAsn1(asn1);
const rsaPublicKey = forge.pki.publicKeyToAsn1(publicKey);
const derPrivateKey = forge.asn1.toDer(rsaPublicKey).getBytes();
const privateKeyArr = this.fromByteStringToArray(derPrivateKey).buffer;
return this.toNSData(privateKeyArr);
}
"use strict";
import * as xmlrpc from "xmlrpc";
import * as forge from "node-forge";
import {Logger} from "../bll/utils/logger";
import {injectable} from "inversify";
import {RemoteLogin} from "./remotelogin";
import {VsCodeUtils} from "../bll/utils/vscodeutils";
import {RcaPublicKey} from "./rcapublickey";
import {MessageConstants} from "../bll/utils/messageconstants";
const BigInteger = forge.jsbn.BigInteger;
const pki = forge.pki;
@injectable()
export class RemoteLoginImpl implements RemoteLogin {
/**
* @param user - user name
* @param password - user password
* @return - Promise. In case of success it returns the line in a format ${sessionId}:${userId}
*/
async authenticate(serverUrl: string, user: string, password: string): Promise {
const client = this.createClient(serverUrl);
const rsaPublicKey: RcaPublicKey = await this.getPublicKey(client);
if (!rsaPublicKey) {
throw MessageConstants.XMLRPC_AUTH_EXCEPTION + " rsaPublicKey is absent";
}
const encPass = rsaPublicKey.encrypt(password);