소스 검색

fix: PKCS8 format private key validating issue #326

Jacky 1 년 전
부모
커밋
979a1d5326
1개의 변경된 파일6개의 추가작업 그리고 1개의 파일을 삭제
  1. 6 1
      internal/cert/helper.go

+ 6 - 1
internal/cert/helper.go

@@ -27,7 +27,12 @@ func IsPrivateKey(pemStr string) bool {
 	}
 
 	_, errECDSA := x509.ParseECPrivateKey(block.Bytes)
-	return errECDSA == nil
+	if errECDSA == nil {
+		return true
+	}
+
+	_, errPKC := x509.ParsePKCS8PrivateKey(block.Bytes)
+	return errPKC == nil
 }
 
 // IsCertificatePath checks if the file at the given path is a certificate or not exists.