Scala SSL configuration


I need to connect to a microservice (using a grpc client) using SSL credentials in Scala.
I have a similar thing in go but i am unable to figure out how to do it in scala

The Go code:

func GetPwd(secret string) (pwd string) {

//CERTS are available in (Ansible FolDER under /Ansible/conf/vault/dev or qa or prod)
caCert, _ := ioutil.ReadFile("/var/mware/cacert.pem")
publicKey, err := ioutil.ReadFile("/var/mware/cert.pem")
privateKey, err := ioutil.ReadFile("/var/mware/privatekey-pck8.pem")

certificate, _ := tls.X509KeyPair(publicKey, privateKey)
hostname, _ := os.Hostname()

vaultRequest := vaultPB.VaultRequest{}
vaultRequest.Name = secret

var tlsConfig tls.Config
caCertPool := x509.NewCertPool()

tlsConfig = tls.Config{
//ClientAuth: tls.RequireAndVerifyClientCert,
Certificates: []tls.Certificate{certificate},
RootCAs: caCertPool,
ServerName: hostname,

tlsConfig.InsecureSkipVerify = true;
creds := credentials.NewTLS(&tlsConfig)
VaultServiceAddress := “localhost:40151”

conn, err := grpc.Dial(VaultServiceAddress, grpc.WithTransportCredentials(creds))

defer conn.Close()
vaultClient := vaultPB.NewVaultServiceClient(conn)

// Contact the server and print out its response.
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
defer cancel()

var response *vaultPB.VaultResponse

response, err = vaultClient.GetvaultPwd(ctx, &vaultRequest)
if err == nil {
return response.Password
“Error while getPwd for::::”+secret, err,
“Node”, “getPwd”)
return “”