I successfully created the myKeystore.bks file which i saved to the located "C:\test\myKeystore.bks". How do i import this keystore now in my app to get the handshake done?
InputStream in = context.getResources().openRawResource(R.raw.mykeystore);
I have following code from Antoine`s Blog which states "Now you can copy the keystore as a raw resource in your android app under res/raw/"
private SSLSocketFactory newSslSocketFactory() {
try {
// Get an instance of the Bouncy Castle KeyStore format
KeyStore trusted = KeyStore.getInstance("BKS");
// Get the raw resource, which contains the keystore with
// your trusted certificates (root and any intermediate certs)
Inpu开发者_如何学编程tStream in = context.getResources().openRawResource(R.raw.mykeystore);
try {
Thank you in advance.
Old question. This answer is relevant to now.
Assuming you're using Android Studio.
To place a file in a specific resource folder In the project explorer,
- Open your project folder.
Locate the res folder and expand the twistie to reveal the different resource folders.
- If you don't have one there called, "Raw", then:
- with the "Res" folder selected in the project explorer,
- go to the File pulldown menu and select, New > Android Resource Directory.
- A form will open, "New Resource Directory". Fill in the following.
- Directory Name: raw
- Resource Type: raw
- Source set: main
Now that you have a "Raw" folder, right click on it and choose to open the location on the file system (on the mac, it's "Reveal in Finder")
Once the folder is opened, drop your keystore in there. Android studio should automatically show it in the Project Explorer inside the Raw folder.
Hope this helps.
Note: I'm using OSX hence the flows may differ, but you get the general idea.
精彩评论