Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue related to SSL inputStream #379

Merged
merged 3 commits into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix issue related to SSL inputStream
  • Loading branch information
Sandeep Kota committed Jul 20, 2022
commit 51672fa64edfd51bbcca832f9f3a43c8803ffde2
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.coralogix.zio.k8s.client.config

import zio.{ System, Task, ZIO }
import zio.{Task, ZIO}

import java.security.SecureRandom
import java.security.cert.X509Certificate
import javax.net.ssl.{ KeyManager, SSLContext, TrustManager, X509TrustManager }
import javax.net.ssl.{KeyManager, SSLContext, TrustManager, X509TrustManager}

object SSL {
def apply(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package com.coralogix.zio.k8s.client
import cats.implicits._
import com.coralogix.zio.k8s.client.model.K8sCluster
import io.circe.generic.semiauto.deriveDecoder
import io.circe.{ parser, Decoder }
import io.circe.{Decoder, parser}
import sttp.client3.UriContext
import sttp.model.Uri
import zio.config._
import zio.nio.file.Path
import zio.process.Command
import zio.{ Layer, RIO, System, Task, ZIO, ZLayer }
import zio.{Layer, RIO, Scope, Task, ZIO, ZLayer}

import java.io.{ ByteArrayInputStream, File, FileInputStream, InputStream }
import java.io.{ByteArrayInputStream, File, FileInputStream, InputStream}
import java.nio.charset.StandardCharsets
import java.util.Base64

Expand Down Expand Up @@ -557,17 +557,15 @@ package object config extends Descriptors {
} yield auth
}

private[config] def loadKeyStream(source: KeySource): ZIO[Any, Throwable, InputStream] =
ZIO.scoped {
ZIO.fromAutoCloseable {
source match {
case KeySource.FromFile(path) =>
ZIO.attempt(new FileInputStream(path.toFile))
case KeySource.FromBase64(base64) =>
ZIO.attempt(new ByteArrayInputStream(Base64.getDecoder.decode(base64)))
case KeySource.FromString(value) =>
ZIO.attempt(new ByteArrayInputStream(value.getBytes(StandardCharsets.US_ASCII)))
}
private[config] def loadKeyStream(source: KeySource): ZIO[Scope, Throwable, InputStream] =
ZIO.fromAutoCloseable {
source match {
case KeySource.FromFile(path) =>
ZIO.attempt(new FileInputStream(path.toFile))
case KeySource.FromBase64(base64) =>
ZIO.attempt(new ByteArrayInputStream(Base64.getDecoder.decode(base64)))
case KeySource.FromString(value) =>
ZIO.attempt(new ByteArrayInputStream(value.getBytes(StandardCharsets.US_ASCII)))
}
}

Expand Down