How to load a local key file using unity WWW class

Hi Guys,
I want to load a certificate using X509Certificate2 class. The code is:

this.keyPath = Application.streamingAssetsPath + "/Key/AMCoIAKeyStore.PFX"
theCertificate = new X509Certificate2(this.keyPath, keyPass)  

It works fine with the windows unity. But when I build it to Android, this Exception Occurs:

I/Unity   ( 4317): DirectoryNotFoundException: Could not find a part of the path "/jar:file:/data/app/com.Test.ConferenceRoom3D-2/base.apk!/assets/Keys/AMCoIAKeyStore.PFX".
I/Unity   ( 4317):   at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) [0x00000] in <filename unknown>:0
I/Unity   ( 4317):   at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess ac
cess, FileShare share) [0x00000] in <filename unknown>:0
I/Unity   ( 4317):   at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,Syst
em.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
I/Unity   ( 4317):   at System.IO.File.OpenRead (System.String path) [0x00000] in <filename unknown> :0  

It looks like, X509Certificate2 tries to use System.IO, and I read somewhere that System.IO can’t retrieve data from jar files so I should use unity’s WWW class to do it. Then i added a class to retrieve bytes of my certificate instead of passing the string of the path to X509Certificate2 (Becauese the X509Certificate2 has another constructor which works with byte array). The code is:

using UnityEngine;
using System.Collections;

public class GetURL : MonoBehaviour {
    public byte[] key = null;
    public void startGetRequest(string url)
    {
        WWW www = new WWW(url);
        StartCoroutine(WaitForRequest(www));
    }
    IEnumerator WaitForRequest(WWW www)
    {
        yield return www;
        this.key = www.bytes;
        if (www.error == null)
        {
            Debug.Log("WWW Ok!: " + www.text);
        }
        else
        {
            Debug.Log("WWW Error: " + www.error);
        }
    }
 }

But now i’m facing a new error in windows unity:

"Could not resolve host: D".  

The “url”, is the path of my certificate. which in this case is:

D:/Project/Assets/StreamingAssets/Key/AMColAKeyStore.PFX  

What did I wrong ?
Is this the correct method to load a .pfx file in android builds ?
Thanks.

try something like

new WWW (“File://”+Application.streamingAssetsPath + “/Key/AMCoIAKeyStore.PFX”)

this is my full code to read a text file

You have to put it inside your project in Assets/StreamingAssets/

  #if UNITY_ANDROID
       string  path = "jar:file://" + Application.dataPath + "!/assets/alphabet.txt";
         WWW wwwfile = new WWW(path);
         while (!wwwfile.isDone) { }
         var filepath = string.Format("{0}/{1}", Application.persistentDataPath, "alphabet.t");
         File.WriteAllBytes(filepath, wwwfile.bytes);
 
         StreamReader wr = new StreamReader(filepath);
             string line;
             while ((line = wr.ReadLine()) != null)
             {
             //your code
             }
  #endif