4
4
using System . Diagnostics ;
5
5
using System . Globalization ;
6
6
using System . IO ;
7
+ using System . Runtime . InteropServices ;
7
8
using System . Text ;
8
9
using System . Threading . Tasks ;
9
10
@@ -37,7 +38,10 @@ public static string Base64Decode(string text)
37
38
/// TODO: kabhishek8260 Remplace the method with X509 Certificate with private key(in dotnet 2.0)
38
39
public static async Task < string > GeneratePfxAsync ( KubernetesClientConfiguration config )
39
40
{
40
- var userHomeDir = Environment . GetEnvironmentVariable ( "HOME" ) ;
41
+ var userHomeDir = RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) ?
42
+ Environment . GetEnvironmentVariable ( "USERPROFILE" ) :
43
+ Environment . GetEnvironmentVariable ( "HOME" ) ;
44
+
41
45
var certDirPath = Path . Combine ( userHomeDir , ".k8scerts" ) ;
42
46
Directory . CreateDirectory ( certDirPath ) ;
43
47
@@ -61,13 +65,8 @@ public static async Task<string> GeneratePfxAsync(KubernetesClientConfiguration
61
65
var process = new Process ( ) ;
62
66
process . StartInfo = new ProcessStartInfo ( )
63
67
{
64
- FileName = @"/bin/bash" ,
65
- Arguments = string . Format (
66
- CultureInfo . InvariantCulture ,
67
- "-c \" openssl pkcs12 -export -out {0} -inkey {1} -in {2} -passout pass:\" " ,
68
- pfxFilePath ,
69
- keyFilePath ,
70
- certFilePath ) ,
68
+ FileName = @"openssl" ,
69
+ Arguments = $ "pkcs12 -export -out { pfxFilePath } -inkey { keyFilePath } -in { certFilePath } -passout pass:",
71
70
CreateNoWindow = true ,
72
71
RedirectStandardError = true ,
73
72
RedirectStandardOutput = true
0 commit comments