Android and certificates

(ndelic) #1

I’m trying to run NanoHttpd websocket server inside Android app using SSL.
For that I need a server certificate but I have no idea how to include it in the project. In Android Studio you can add raw folder to res, but it appears it’s not possible in Fire. Is there any other way to do it? Can apk signing certificate be used as SSL certificate? Does anybody have any experience with that?

(marc hoffman) #2

Define “not possible”? you can put any files and subfolders you like into /res?

(ndelic) #3

Oh, ok, my bad. As you can see in the screenshot, “raw” folder is crossed over, so I assumed only “predefined” folders are allowed. If that doesn’t matter I’ll check it out. Maybe you should remove that cross in future versions of Fire to avoid confusion.


(ndelic) #4

I got it, it appears to be a bug in Fire. New folder is added as NewFolder on disk and when I rename it to raw, it appears renamed in Fire IDE, but it is not renamed on disk.

(marc hoffman) #5

Curious. I’ll look into that.

That explains why it struck out though — that means “this thing is in the project, but doesn’t exists on disk”.

(ndelic) #6

Yes, once I renamed it on disk the cross disappeared. However, I still can’t add certificate to the newly created folder. I right-click it, select Add Existing File(s), select the certificate in the dialog and click Add File(s) but nothing happens, the certificate is not added to the folder.

Update: It works if I add the cert file manually in Finder.

(marc hoffman) #7

“Add Existing File(s)” adds the files to the project at their current location, it will not move them to the folder. So that part is as designed. The file will be showing in your project, just not where you’re looking.

(marc hoffman) #8

Reproduced; fixing.

(ndelic) #9

“Add Existing File(s)” adds the files to the project at their current location, it will not move them to the folder.

I get it, but they don’t show in IDE once they are supposed to be added to /res/raw (as links), the folder appears empty in IDE. I see that the files are added under Files above, which is fine. But it doesn’t make sense that I right-click res/raw, add file(s) to it, but then they appear in another location in project tree. It’s no big deal but it is a bit inconsistent.

(marc hoffman) #10

Right. I removed that menu item there, as it’s confusing/misleading.

“Add Existing Files…” will add a file to the project, at its current location. Where that location is on disk will drive where it shows in the project, as (virtual folders aside) the project hierarchy reflects the on-disk hierarchy of files.