How to use pem.createCertificateAsync method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

harServer.js

Source:harServer.js Github

copy

Full Screen

...175 self.config.sslKey = key.toString();176 });177 } else if (self.config.generateKey) {178 console.log('Generating SSL key and cert');179 return pem.createCertificateAsync({days: 10, selfSigned: true}).then(function (keys) {180 self.config.sslKey = keys.serviceKey;181 self.config.sslCert = keys.certificate;182 });183 }184 }).then(function () {185 var protocol = '';186 if (self.config.useSSL) {187 protocol = 'HTTPS';188 server = https.createServer({key: self.config.sslKey, cert: self.config.sslCert}, this._requestHandler);189 console.log('To load the SSL har-server in Chrome, add the --ignore-certificate-errors command line switch');190 } else {191 protocol = 'HTTP';192 server = http.createServer(this._requestHandler);193 }...

Full Screen

Full Screen

safari-ssl-e2e-specs.js

Source:safari-ssl-e2e-specs.js Github

copy

Full Screen

...25 driver = wd.promiseChainRemote(HOST, PORT);26 server = await startServer(PORT, HOST);27 // Create a random pem certificate28 let privateKey = await pem.createPrivateKeyAsync();29 let keys = await pem.createCertificateAsync({days:1, selfSigned: true, serviceKey: privateKey.key});30 pemCertificate = keys.certificate;31 // Host an SSL server that uses that certificate32 const serverOpts = {key: keys.serviceKey, cert: pemCertificate};33 sslServer = https.createServer(serverOpts, (req, res) => {34 res.end('Arbitrary text');35 }).listen(9758);36 });37 after(async () => {38 if (server) {39 await server.close();40 }41 if (sslServer) {42 await sslServer.close();43 }...

Full Screen

Full Screen

ssl-specs.js

Source:ssl-specs.js Github

copy

Full Screen

...10 let caps = Object.assign({}, desired);11 before(async function () {12 // Create an HTTPS server with a random pem certificate13 let privateKey = await pem.createPrivateKeyAsync();14 let keys = await pem.createCertificateAsync({days: 1, selfSigned: true, serviceKey: privateKey.key});15 let pemCertificate = keys.certificate;16 sslServer = https.createServer({key: keys.serviceKey, cert: pemCertificate}, function (req, res) {17 res.end('Arbitrary text');18 }).listen(9758);19 caps.customSSLCert = pemCertificate;20 caps.fullReset = false;21 caps.noReset = true;22 });23 const driver = setup(this, caps).driver;24 after(async function () {25 if (sslServer) {26 await sslServer.close();27 }28 });...

Full Screen

Full Screen

dev_cert.js

Source:dev_cert.js Github

copy

Full Screen

...20 organization: 'davelee.io',21 commonName: hostname22})23 .then((data) => {24 return pem.createCertificateAsync({25 extFile: './src/server/dev_cert/v3.ext',26 csr: data.csr,27 days: 1024,28 })29 })30 .then((data) => {31 fs.writeFileSync('./src/server/dev_cert/key.pem', data.serviceKey);32 fs.writeFileSync('./src/server/dev_cert/cert.pem', data.certificate);33 })34 .then(() => {35 console.log('Dev Cert successfully created, Run:');36 console.log('sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain src/server/dev_cert/cert.pem');37 })38 .catch((err) => {...

Full Screen

Full Screen

server.js

Source:server.js Github

copy

Full Screen

1/*2Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.3SPDX-License-Identifier: MIT-04*/5var Promise=require('bluebird')6var https = require('https');7var http = require('http');8var fs=require('fs')9var pem=require('pem')10var BIND_ADDRESS ='0.0.0.0' || '127.0.0.1';11var PORT = 8000;12module.exports=function(app){13 return Promise.promisifyAll(pem).createCertificateAsync({days:30, selfSigned:true})14 .then(function(keys){15 var server=https.createServer({16 key: keys.serviceKey, 17 cert: keys.certificate18 },app)19 var redirect=http.createServer(function (req, res) {20 var host=req.headers['host'].split(':')[0]21 res.writeHead(301, { 22 "Location": "https://" + host+':'+PORT + req.url 23 });24 res.end();25 })26 return {27 start:function(){28 server.listen(PORT);29 redirect.listen(PORT+1);30 console.log('Listening at https://' + BIND_ADDRESS + ':' + PORT);31 console.log('Listening at http://' + BIND_ADDRESS + ':' + (PORT+1));32 },33 stop:function(){34 server.close()35 redirect.close()36 }37 }38 })...

Full Screen

Full Screen

certificates.js

Source:certificates.js Github

copy

Full Screen

...3const pem = Promise.promisifyAll(require('pem'))4const fs = require('fs')5class CertificateController {6 * postResource () {7 const pemResult = yield pem.createCertificateAsync({8 serviceKey: fs.readFileSync(process.env.CA_KEY_FILE, 'utf-8'),9 serviceKeyPassword: process.env.CA_KEY_PASSPHRASE,10 serviceCertificate: fs.readFileSync(process.env.CA_CERT, 'utf-8'),11 csr: this.request.body.certificate_signing_request,12 days: 375,13 serial: 1004,14 extFile: process.env.CA_CONFIG_FILE15 })16 this.status = 20117 this.body = {18 ca_chain: process.env.CA_CHAIN,19 certificate: pemResult.certificate20 }21 }...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1'use strict';2import Promise from 'bluebird';3import Pem from 'pem';4Promise.promisifyAll(Pem);5const generatePrivateKey = async () => {6 let { serviceKey } = await Pem.createCertificateAsync();7 return serviceKey;8};9const generatePublicKey = async (privateKey) => {10 let { publicKey } = await Pem.getPublicKeyAsync(privateKey);11 return publicKey;12};13const generateKeys = async () => {14 const privateKey = await generatePrivateKey();15 const publicKey = await generatePublicKey(privateKey);16 return { privateKey, publicKey };17};18let keys;19export default {20 async keys() {21 if (!keys) {22 keys = await generateKeys();23 }24 return keys;25 },26 reset() {27 keys = null;28 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const pem = require('pem');2pem.createCertificate({ days: 1, selfSigned: true }, function(err, keys) {3 if (err) { throw err; }4 console.log('keys: ' + keys.serviceKey);5});6const forge = require('node-forge');7const pki = forge.pki;8const keys = pki.rsa.generateKeyPair(2048);9const cert = pki.createCertificate();10cert.publicKey = keys.publicKey;11cert.serialNumber = '01';12cert.validity.notBefore = new Date();13cert.validity.notAfter = new Date();14cert.validity.notAfter.setFullYear(cert.validity.notBefore.getFullYear() + 1);15const attrs = [{16}, {17}, {18}, {19}, {20}, {21}];22cert.setSubject(attrs);23cert.setIssuer(attrs);24cert.setExtensions([{25}, {26}, {27 altNames: [{28 }]29}, {30}]);31cert.sign(keys.privateKey, forge.md.sha256.create());32const pem = pki.certificateToPem(cert);33console.log('Certificate: ' + pem);

Full Screen

Using AI Code Generation

copy

Full Screen

1const {pem} = require('appium-xcuitest-driver');2const {fs} = require('appium-support');3async function main () {4 const cert = await pem.createCertificateAsync();5 await fs.writeFile('cert.pem', cert.certificate);6 await fs.writeFile('key.pem', cert.key);7}8main();9#import <Foundation/Foundation.h>10#import <XCTest/XCTest.h>11- (void)setUp {12 [super setUp];13}14- (void)tearDown {15 [super tearDown];16}17- (void)testExample {18}19const {exec} = require('teen_process');20const {fs} = require('appium-support');21const {pem} = require('appium-xcuitest-driver');22async function main () {23 const cert = await pem.createCertificateAsync();24 await fs.writeFile('cert.pem', cert.certificate);25 await fs.writeFile('key.pem', cert.key);26 await exec('xcodebuild', [

Full Screen

Using AI Code Generation

copy

Full Screen

1const { createCertificateAsync } = require('appium-xcuitest-driver').pem;2const certOpts = {3};4createCertificateAsync(certOpts)5 .then((cert) => {6 console.log(cert);7 });8const { createCertificateAsync } = require('appium-xcuitest-driver').pem;9const certOpts = {10};11createCertificateAsync(certOpts)12 .then((cert) => {13 console.log(cert);14 });15const { createCertificateAsync } = require('appium-xcuitest-driver').pem;16const certOpts = {17};18createCertificateAsync(certOpts)19 .then((cert) => {20 console.log(cert);21 });22const { createCertificateAsync } = require('appium-xcuitest-driver').pem;23const certOpts = {24};25createCertificateAsync(certOpts)26 .then((cert) => {27 console.log(cert);28 });29const { createCertificateAsync } = require('appium-xcuitest-driver').pem;30const certOpts = {31};32createCertificateAsync(certOpts)33 .then((cert) => {34 console.log(cert);35 });36const { createCertificateAsync } = require('appium-xcuitest-driver').pem;37const certOpts = {38};39createCertificateAsync(certOpts)40 .then((cert) => {41 console.log(cert);42 });

Full Screen

Using AI Code Generation

copy

Full Screen

1var pem = require('pem');2var fs = require('fs');3var keychainPath = '/Users/<your username>/Library/Keychains/login.keychain';4pem.createCertificate({days:1, selfSigned:true}, function(err, keys) {5 if (err) {6 console.log(err);7 return;8 }9 var certPath = '/Users/<your username>/Desktop/cert.pem';10 var keyPath = '/Users/<your username>/Desktop/key.pem';11 fs.writeFileSync(certPath, keys.certificate);12 fs.writeFileSync(keyPath, keys.clientKey);13 var cmd = 'security import ' + certPath + ' -k ' + keychainPath + ' -T /usr/bin/codesign';14 require('child_process').exec(cmd, function(err, stdout, stderr) {15 console.log(stdout);16 console.log(stderr);17 console.log(err);18 });19});20var pem = require('pem');21var fs = require('fs');22var keychainPath = '/Users/<your username>/Library/Keychains/login.keychain';23pem.createCertificate({days:1, selfSigned:true}, function(err, keys) {24 if (err) {25 console.log(err);26 return;27 }28 var certPath = '/Users/<your username>/Desktop/cert.pem';29 var keyPath = '/Users/<your username>/Desktop/key.pem';30 fs.writeFileSync(certPath, keys.certificate);31 fs.writeFileSync(keyPath, keys.clientKey);32 var cmd = 'security import ' + certPath + ' -k ' + keychainPath + ' -T /usr/bin/codesign';33 require('child_process').exec(cmd, function(err, stdout, stderr) {34 console.log(stdout);35 console.log(stderr);36 console.log(err);37 });38});39var pem = require('pem');40var fs = require('fs');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { createCertificateAsync } = require('appium-xcuitest-driver/lib/commands/certificate');2const { fs } = require('appium-support');3const { exec } = require('teen_process');4const B = require('bluebird');5const { logger } = require('appium-support');6async function main() {7 const cert = await createCertificateAsync();8 const certPath = await fs.writeFile('cert.pem', cert.pem);9 await exec('security', ['add-trusted-cert', '-d', '-r', 'trustRoot', '-k', '/Library/Keychains/System.keychain', certPath]);10}11main();12const { createCertificateAsync } = require('appium-xcuitest-driver/lib/commands/certificate');13const { fs } = require('appium-support');14const { exec } = require('teen_process');15const B = require('bluebird');16const { logger } = require('appium-support');17async function main() {18 const cert = await createCertificateAsync();19 const certPath = await fs.writeFile('cert.pem', cert.pem);20 await exec('security', ['add-trusted-cert', '-d', '-r', 'trustRoot', '-k', '/Library/Keychains/System.keychain', certPath]);21}22main();23const { createCertificateAsync } = require('appium-xcuitest-driver/lib/commands/certificate');24const { fs } = require('appium-support');25const { exec } = require('teen_process');26const B = require('bluebird');27const { logger } = require('appium-support');28async function main() {29 const cert = await createCertificateAsync();30 const certPath = await fs.writeFile('cert.pem', cert.pem);31 await exec('security', ['add-trusted-cert', '-d', '-r', 'trustRoot', '-k', '/Library/Keychains/System.keychain', certPath]);32}33main();

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Appium Xcuitest Driver automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Sign up Free
_

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful