How to create secure credentials with custom connection options?
- Dominant language
- TypeScript
- Stars
- 4.8k
- Forks
- 716
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 10
Description
I have this code at the moment that I use to increase the frame and window sizes:
```
class CustomChannelCred extends ChannelCredentials {
constructor(callCredentials?: CallCredentials) {
super();
}
compose(callCredentials: CallCredentials): never {
throw new Error("Cannot compose insecure credentials");
}
_getConnectionOptions(): any {
return {
settings: {
// This will increase the http2 frame size. Default is 16384, which is too small.
maxFrameSize: 4194304,
// The initial window size set here is overridden later. We need to patch the grpc-js library to allow this.
initialWindowSize: 4194304,
maxHeaderListSize: 8192,
enablePush: false,
maxConcurrentStreams: 0,
},
};
}
_isSecure(): boolean {
return false;
}
_equals(other: ChannelCredentials): boolean {
return other instanceof CustomChannelCred;
}
}
```
Previously I was connecting to an upstream without SSL but that has changed. I can successfully connect to the upstream if I scrap all of that and just use `credentials.createSsl()`, but then I'm not setting my custom connection options. Making `_isSecure` return true also doesn't work.
I've tried a variety of ways to create a custom channel credentials class, composing with CallCredentials, etc. but none of that seems to work. I'm reaching for some kind of `compose` function that works with another instance of ChannelCredentials, but it doesn't exist.
I looked at these docs and they didn't really help either: https://grpc.io/docs/guides/auth/#nodejs.
In short, how can I modify the connection options on an instance of ChannelCredentials?
Contributor guide
Assessment
This issue has not been assessed yet.