Skip to content

Commit e675406

Browse files
authored
Merge pull request #1968 from murgatroid99/grpc-js_certificate_check_callback
grpc-js: Provide full certificate in `checkServerIdentity` callback
2 parents bf11e4b + 472baec commit e675406

File tree

1 file changed

+5
-20
lines changed

1 file changed

+5
-20
lines changed

packages/grpc-js/src/channel-credentials.ts

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,6 @@ function verifyIsBufferOrNull(obj: any, friendlyName: string): void {
2727
}
2828
}
2929

30-
/**
31-
* A certificate as received by the checkServerIdentity callback.
32-
*/
33-
export interface Certificate {
34-
/**
35-
* The raw certificate in DER form.
36-
*/
37-
raw: Buffer;
38-
}
39-
4030
/**
4131
* A callback that will receive the expected hostname and presented peer
4232
* certificate as parameters. The callback should return an error to
@@ -45,7 +35,7 @@ export interface Certificate {
4535
*/
4636
export type CheckServerIdentityCallback = (
4737
hostname: string,
48-
cert: Certificate
38+
cert: PeerCertificate
4939
) => Error | undefined;
5040

5141
function bufferOrNullEqual(buf1: Buffer | null, buf2: Buffer | null) {
@@ -192,15 +182,10 @@ class SecureChannelCredentialsImpl extends ChannelCredentials {
192182
cert: certChain || undefined,
193183
ciphers: CIPHER_SUITES,
194184
});
195-
this.connectionOptions = { secureContext };
196-
if (verifyOptions && verifyOptions.checkServerIdentity) {
197-
this.connectionOptions.checkServerIdentity = (
198-
host: string,
199-
cert: PeerCertificate
200-
) => {
201-
return verifyOptions.checkServerIdentity!(host, { raw: cert.raw });
202-
};
203-
}
185+
this.connectionOptions = {
186+
secureContext,
187+
checkServerIdentity: verifyOptions?.checkServerIdentity
188+
};
204189
}
205190

206191
compose(callCredentials: CallCredentials): ChannelCredentials {

0 commit comments

Comments
 (0)