Skip to content

Commit 4f86543

Browse files
committed
Expose the cert fingerprint from the server config
1 parent 01ee528 commit 4f86543

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/httptoolkit-server.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as events from 'events';
44
import corsGate = require('cors-gate');
55
import { GraphQLServer } from 'graphql-yoga';
66
import { GraphQLScalarType } from 'graphql';
7+
import { generateSPKIFingerprint } from 'mockttp';
78

89
import { HtkConfig } from './config';
910
import { reportError, addBreadcrumb } from './error-tracking';
@@ -36,6 +37,7 @@ const typeDefs = `
3637
type InterceptionConfig {
3738
certificatePath: String!
3839
certificateContent: String!
40+
certificateFingerprint: String!
3941
}
4042
4143
type Interceptor {
@@ -62,7 +64,11 @@ const buildResolvers = (
6264
interceptors: () => _.values(interceptors),
6365
config: () => ({
6466
certificatePath: config.https.certPath,
65-
certificateContent: config.https.certContent
67+
certificateContent: config.https.certContent,
68+
// We could calculate this client side, but it normally requires node-forge or
69+
// some other heavyweight crypto lib, and we already have that here, so it's
70+
// convenient to do it up front.
71+
certificateFingerprint: generateSPKIFingerprint(config.https.certContent)
6672
}),
6773
networkInterfaces: () => os.networkInterfaces()
6874
},

0 commit comments

Comments
 (0)