I have wiremock running on my local, using the jar...
# general
s
I have wiremock running on my local, using the jars wiremock-grpc-extension-standalone-0.4.0.jar and wiremock-standalone-3.3.1.jar I am able to mock the grpc calls on my local as i was not using TLS verification on local. But when I have deployed wiremock in our gke cluster, I was not getting mock responses, typically because this deployment doesnot have certificates. I have added certificates in the /certificates folder. still facing the same issue. [ERROR] UNAVAILABLE: io exceptionChannel Pipeline: [SslHandler#0, ProtocolNegotiators$ClientTlsHandler#0, WriteBufferingAndExceptionHandler#0, DefaultChannelPipeline$TailContext#0] Can someone help me out in providing certificates to wiremock jar??
t
To provide your own certificate to WireMock you need to bundle it into a Java keystore file and set the path to this on WireMock’s startup via the
--https-keystore
parameter. Alternatively you could use an external TLS terminator e.g. nginx.
s
Still facing the same issue. I have provided a .jks file
t
It might be worth validating the JKS file by starting WireMock locally with it and using e.g. grpcurl to test your gRPC mock.
s
Exception in thread "main" java.io.IOException: Keystore was tampered with, or password was incorrect getting this error when running in local. but i haven't provided password while building the app
t
Is they keystore file password protected?
s
yes
t
OK, then you also need to supply
--keystore-password
and possibly
--key-manager-password
All these options are documented here BTW: https://wiremock.org/docs/standalone/java-jar/
s
Do i need to expose 8080 port or 8443 port for grpc??
t
Depends whether you want to serve it over TLS or not.
s
Yes, i want to serve it on tls
t
OK, then make sure the HTTPS port is set on startup to 8443 then expose that.
s
Copy code
server does not support the reflection API
Can we enable server reflection for the jar??
t
I’ve never seen this error before so will need a lot more context to understand what’s happening: • How are you starting WireMock - full command line? • What output do you see on startup? • Where are you seeing this error? • Is there an associated stack trace?
s
Copy code
ENTRYPOINT exec java $JAVA_OPTS -cp wiremock-standalone.jar:wiremock-grpc-extension-standalone.jar wiremock.Run --port 8080 --https-port=8443 --root-dir wiremock-data --https-keystore=keystore_new.p12 --keystore-type pkcs12  --https-truststore=keystore_new.p12 --truststore-type=pkcs12
This is my docker command. Im able to hit through postman, but not through my other grpc service. I can clearly understand it is a certificate issue. openssl pkcs12 -export -out keystore_new.p12 -inkey mercatorPrivateKey.key -in mercatorCert.crt Command used to generate keystore ^^ But still not working, can u help me out??
t
Have you built a DSC file and put it in the grpc folder mounted in the container?
s
yes
t
When you hit it through Postman is that on the plain text port or TLS?
s
with TLS
t
BTW, WireMock genuinely doesn’t support server reflection at the moment, but it shouldn’t be necessary if you’ve got the proto on both sides.
s
server reflection is not a problem,
t
OK, what error do you see now?
s
[SslHandler#0, ProtocolNegotiators$ClientTlsHandler#0, WriteBufferingAndExceptionHandler#0, DefaultChannelPipeline$TailContext#0]
same error from the begining
t
Is this being thrown by your client?
Is there a stack trace or any other context?
s
yes
only this log gets printed io.grpc.StatusRuntimeException: UNAVAILABLE: io exceptionChannel Pipeline: [SslHandler#0, ProtocolNegotiators$ClientTlsHandler#0, WriteBufferingAndExceptionHandler#0, DefaultChannelPipeline$TailContext#0]
My client is a grpc springboot application.
t
I don’t know what that error means unfortunately. I’d hazard a guess that the certificate configuration hasn’t worked properly and so the client doesn’t trust WireMock. But it’s hard be sure with such a cryptic message.
s
is there a way that i can disbale ssl verification or something of this sort??
t
Most/all of the major HTTP clients will can be configured to trust all certificates, usually by supplying your own SSLContext when constructing the client. I don’t know how do it in Spring/gRPC specifically.