-
I'm not able to connect to a device that is using self signed certificate.
I tried this, but checkServerIdentity is not being called
This is the error in subchannel.js
|
Beta Was this translation helpful? Give feedback.
Answered by
aikoven
Jul 28, 2022
Replies: 1 comment 1 reply
-
I found one way to do it by overriding import {CallCredentials} from '@grpc/grpc-js';
import {ChannelCredentials, createChannel} from 'nice-grpc';
import {ConnectionOptions} from 'tls';
class InsecureSSLChannelCredentials extends ChannelCredentials {
constructor(
private parent: ChannelCredentials = ChannelCredentials.createSsl(),
) {
super();
}
_getConnectionOptions(): ConnectionOptions | null {
return {
...this.parent._getConnectionOptions(),
rejectUnauthorized: false,
};
}
compose(callCredentials: CallCredentials): ChannelCredentials {
return new InsecureSSLChannelCredentials(
this.parent.compose(callCredentials),
);
}
_isSecure(): boolean {
return this.parent._isSecure();
}
_equals(other: ChannelCredentials): boolean {
return (
other instanceof InsecureSSLChannelCredentials &&
other.parent._equals(this.parent)
);
}
}
const channel = createChannel(
`${host}:${port}`,
new InsecureSSLChannelCredentials(),
); |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
jkristia
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I found one way to do it by overriding
ConnectionOptions
inChannelCredentials
to addrejectUnauthorized: false
: