title: Permission denied error while reading openssl.cnf file
body: <p>I am trying to generate SSL certificate via powershell and using openssl for it.
  Below is my code:</p>
  <pre><code>Function new-csr {
  [CmdletBinding()]
  Param(
   $country, #2 please enter char country code
   $state, #state 
   $locality, #city
   $org, # organization name
   $ou, # orhanization unit name
   $cn, # common name  hostname
   $email, # contact email
   $randPath, # path for file
   $privateKeyPath, # path to private key
   $csrPath # path to certificate signin request (output) 
  
  )
  
  # if private key has not been created , create one
  if(-not (Test-Path $privateKeyPath)){
      openssl genrsa -out $privateKeyPath 2048
  }
  
  if(-not(Test-Path $randPath)){
      openssl rand -out $randPath
  }
  
  $subject = &quot;`&quot;/C=$country/ST=$state/L=$locality/O=$org/OU=$ou/CN=$cn`&quot;&quot;
  
  openssl req -new -key $privateKeyPath -rand $randPath -subj $subject -out $csrPath
  }
  </code></pre>
  <p>When trying to execute it in PowerShell under Admin permission. I get permission denied error.
  My guess is this might be due to the fact that .cnf file is under Program Files. So should i try uninstalling PowerShell and install again this time outside Program Files folder?</p>
  <blockquote>
  <p>Can't open C:\Program Files\OpenSSL-Win64\bin\cnf for reading, Permission denied
  9604:error:02001005:system library:fopen:Input/output error:crypto\bio\bss_file.c:69:fopen('C:\Program Files\OpenSSL-Win64\bin\cnf','rb')
  9604:error:2006D002:BIO routines:BIO_new_file:system lib:crypto\bio\bss_file.c:78:
  9604:error:0E078002:configuration file routines:def_load:system lib:crypto\conf\conf_def.c:170:
  9604:error:02001005:system library:fopen:Input/output error:crypto\bio\bss_file.c:69:fopen('C:\Program Files\OpenSSL-Win64\bin\cnf','r')
  9604:error:2006D002:BIO routines:BIO_new_file:system lib:crypto\bio\bss_file.c:78:</p>
  </blockquote>
  <p>For OpenSSL configuration, I have added both environment variable as well as user variable:</p>
  <blockquote>
  <p>EnvironmentVariable: Path as
  C:\Program Files\OpenSSL-Win64\bin<br />
  UserVariable as
  OPENSSL_CONF= C:\Program Files\OpenSSL-Win64\bin\cnf</p>
  </blockquote>