Skip to content

Commit 3380d9d

Browse files
committed
Revert "Restore skipSSLValidation flag"
This reverts commit 7e9aad1. Accidental push to master branch
1 parent 7e9aad1 commit 3380d9d

3 files changed

Lines changed: 21 additions & 13 deletions

File tree

packages/apollo-language-server/src/schema/providers/introspection.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ import {
1010
IntrospectionQuery,
1111
parse
1212
} from "graphql";
13-
import { Agent } from "http";
13+
import { Agent, AgentOptions } from "https";
1414
import { fetch } from "apollo-env";
15+
import { URL } from "url";
16+
1517
import { RemoteServiceConfig } from "../../config";
1618
import { GraphQLSchemaProvider, SchemaChangeUnsubscribeHandler } from "./base";
1719

@@ -21,11 +23,23 @@ export class IntrospectionSchemaProvider implements GraphQLSchemaProvider {
2123
async resolveSchema() {
2224
if (this.schema) return this.schema;
2325
const { skipSSLValidation, url, headers } = this.config;
24-
const options: HttpLink.Options = {
25-
uri: url,
26-
fetch,
27-
...(skipSSLValidation && { fetchOptions: { agent: new Agent() } })
28-
};
26+
let options: HttpLink.Options = { uri: url, fetch };
27+
28+
if (skipSSLValidation) {
29+
const urlObject = new URL(url);
30+
const host = urlObject.host;
31+
const port = +urlObject.port || 443;
32+
33+
const agentOptions: AgentOptions = {
34+
host: host,
35+
port: port,
36+
rejectUnauthorized: false
37+
};
38+
39+
const agent = new Agent(agentOptions);
40+
41+
options.fetchOptions = { agent: agent };
42+
}
2943

3044
const { data, errors } = (await toPromise(
3145
linkExecute(createHttpLink(options), {

packages/apollo/src/Command.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ export interface Flags {
3535
engine?: string;
3636
frontend?: string;
3737
tag?: string;
38-
skipSSLValidation?: boolean;
3938
}
4039

4140
const headersArrayToObject = (
@@ -134,8 +133,7 @@ export abstract class ProjectCommand extends Command {
134133
service: {
135134
endpoint: {
136135
url: flags.endpoint,
137-
headers: headersArrayToObject(flags.header),
138-
...(flags.skipSSLValidation && { skipSSLValidation: true })
136+
headers: headersArrayToObject(flags.header)
139137
}
140138
}
141139
});

packages/apollo/src/commands/service/download.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ export default class ServiceDownload extends ProjectCommand {
1414
char: "t",
1515
description: "The published tag to check this service against",
1616
default: "current"
17-
}),
18-
skipSSLValidation: flags.boolean({
19-
char: "k",
20-
description: "Allow connections to an SSL site without certs"
2117
})
2218
};
2319

0 commit comments

Comments
 (0)