diff --git a/README.md b/README.md index 405bf2ad..ca5f2bb8 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,8 @@ To avoid providing credentials with every command, you can login once. Currently > Warning! Using this feature will store your login credentials on disk in plain text. +> To skip certificate validation connecting to On-Prem Azure DevOps Server you can use parameter `--skip-cert-validation` + #### Personal access token Start by [creating a personal access token](http://roadtoalm.com/2015/07/22/using-personal-access-tokens-to-access-visual-studio-online) and paste it into the login command. diff --git a/app/exec/login.ts b/app/exec/login.ts index bda9205c..f5be30cc 100644 --- a/app/exec/login.ts +++ b/app/exec/login.ts @@ -24,8 +24,12 @@ export class Login extends TfCommand { public async exec(): Promise { trace.debug("Login.exec"); return this.commandArgs.serviceUrl.val().then(async collectionUrl => { + const skipCertValidation = await this.commandArgs.skipCertValidation.val(false); + const authHandler = await this.getCredentials(collectionUrl, false); - const webApi = await this.getWebApi(); + const webApi = await this.getWebApi({ + ignoreSslError: skipCertValidation + }); const locationsApi = await webApi.getLocationsApi(); try { diff --git a/app/lib/tfcommand.ts b/app/lib/tfcommand.ts index a77d9569..4c8b5ff8 100644 --- a/app/lib/tfcommand.ts +++ b/app/lib/tfcommand.ts @@ -18,6 +18,7 @@ import fsUtils = require("./fsUtils"); import { promisify } from "util"; import trace = require("./trace"); import version = require("./version"); +import { IRequestOptions } from "azure-devops-node-api/interfaces/common/VsoBaseInterfaces"; export interface CoreArguments { [key: string]: args.Argument; @@ -37,6 +38,7 @@ export interface CoreArguments { noPrompt: args.BooleanArgument; noColor: args.BooleanArgument; debugLogStream: args.StringArgument; + skipCertValidation: args.BooleanArgument; } export interface Executor { @@ -334,6 +336,13 @@ export abstract class TfCommand { args.StringArgument, "stdout", ); + this.registerCommandArgument( + "skipCertValidation", + "Skip Certificate Validation", + "Skip certificate validation during login", + args.BooleanArgument, + "false", + ); } /** @@ -409,11 +418,11 @@ export abstract class TfCommand { }); } - public getWebApi(): Promise { + public getWebApi(options?: IRequestOptions): Promise { return this.commandArgs.serviceUrl.val().then(url => { return this.getCredentials(url).then(handler => { this.connection = new TfsConnection(url); - this.webApi = new WebApi(url, handler); + this.webApi = new WebApi(url, handler, options); return this.webApi; }); }); @@ -549,7 +558,7 @@ export abstract class TfCommand { if (this.serverCommand) { result += eol + cyan("Global server command arguments:") + eol; - ["authType", "username", "password", "token", "serviceUrl", "fiddler", "proxy"].forEach(arg => { + ["authType", "username", "password", "token", "serviceUrl", "fiddler", "proxy", "skipCertValidation"].forEach(arg => { result += singleArgData(arg, 11); }); } diff --git a/package-lock.json b/package-lock.json index 53715e93..97127e06 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "tfx-cli", - "version": "0.12.0", + "version": "0.13.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 8e30c78e..ba0a2ab0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tfx-cli", - "version": "0.12.0", + "version": "0.13.0", "description": "CLI for Azure DevOps Services and Team Foundation Server", "repository": { "type": "git",