mirror of https://github.com/grpc/grpc-node.git
grpc-js: Provide full certificate in checkServerIdentity callback
This commit is contained in:
parent
fe5806171f
commit
472baec1ff
|
@ -27,16 +27,6 @@ function verifyIsBufferOrNull(obj: any, friendlyName: string): void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* A certificate as received by the checkServerIdentity callback.
|
|
||||||
*/
|
|
||||||
export interface Certificate {
|
|
||||||
/**
|
|
||||||
* The raw certificate in DER form.
|
|
||||||
*/
|
|
||||||
raw: Buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A callback that will receive the expected hostname and presented peer
|
* A callback that will receive the expected hostname and presented peer
|
||||||
* certificate as parameters. The callback should return an error to
|
* certificate as parameters. The callback should return an error to
|
||||||
|
@ -45,7 +35,7 @@ export interface Certificate {
|
||||||
*/
|
*/
|
||||||
export type CheckServerIdentityCallback = (
|
export type CheckServerIdentityCallback = (
|
||||||
hostname: string,
|
hostname: string,
|
||||||
cert: Certificate
|
cert: PeerCertificate
|
||||||
) => Error | undefined;
|
) => Error | undefined;
|
||||||
|
|
||||||
function bufferOrNullEqual(buf1: Buffer | null, buf2: Buffer | null) {
|
function bufferOrNullEqual(buf1: Buffer | null, buf2: Buffer | null) {
|
||||||
|
@ -192,15 +182,10 @@ class SecureChannelCredentialsImpl extends ChannelCredentials {
|
||||||
cert: certChain || undefined,
|
cert: certChain || undefined,
|
||||||
ciphers: CIPHER_SUITES,
|
ciphers: CIPHER_SUITES,
|
||||||
});
|
});
|
||||||
this.connectionOptions = { secureContext };
|
this.connectionOptions = {
|
||||||
if (verifyOptions && verifyOptions.checkServerIdentity) {
|
secureContext,
|
||||||
this.connectionOptions.checkServerIdentity = (
|
checkServerIdentity: verifyOptions?.checkServerIdentity
|
||||||
host: string,
|
};
|
||||||
cert: PeerCertificate
|
|
||||||
) => {
|
|
||||||
return verifyOptions.checkServerIdentity!(host, { raw: cert.raw });
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
compose(callCredentials: CallCredentials): ChannelCredentials {
|
compose(callCredentials: CallCredentials): ChannelCredentials {
|
||||||
|
|
Loading…
Reference in New Issue