The framework fairly neatly packages the whole process.
The origin of the signature testing process is the Adobe article here, where you can also download a compiled code swc of the necessary flex-only classes if you're working in Flash.
The air application I've built as proof-of-principle achieves the following:
- Modules with matching signatures are loaded to the app sandbox (if requested).
- Modules without matching signatures requesting app sandbox loading are rejected.
- Modules can also be loaded to the non-application sandbox.
It demonstrates:
- That app sandbox loaded modules can write to the file system (they put a directory on your desktop).
- That non-app sandbox loaded modules are prevented from writing to the file system.
- That both app and non-app sandbox loaded modules can pass library assets to the main application to be added to the display list.
It has a lot of user feedback / developer feedback built in. In the absence of the ability to trace in the air application itself I'm listening for this feedback and displaying it in a textarea in the main application.
Currently the information about what to load and how to load it, and where to find the .zip assets on a server to install modules, is all contained in moduleData.xml inside the applicationFlasAndCode folder. When you start the application you must browse to this file.
To use the framework:
- Use ModuleXMLLoader to load an xml document containing your module information.
- This creates a strongly typed iterator: ModuleDescriptionIterator.
- Instantiate ModuleChainLoader, passing it that iterator.
- Listen for the ModuleEvent.MODULE_LOADING_COMPLETE event.
- Ask the moduleChainLoader to startLoadingModules().
- When you handle the loading complete event, run getModuleDictionary().
- Access your modules from the ModuleDictionary using getModule() and getSandboxedModule(). You pass the module's unique name to those functions. They pass back the required module.
Any questions at all, post them here or email me.
How secure is secure?
I'm building an enterprise training application. It already exists in AIR, but we're moving to a modular system because our users don't have the permissions required to run the automatic updates.
Secure, for me, is secure enough not to be the preferred target for a malicious attack. Nothing is impossible, but I want to make it sufficiently difficult / tedious that anyone intending to cause trouble looks elsewhere to do it.
Notes:
In my own final application the xml will be a secure data stream coming from a server.
If you want to keep my xml structure you can use the ModuleXMLLoader class as is, but I've kept it as a separate stage in the process so that you can make changes to this.
Some possible gotchas to avoid:
- The example module flas have classes which extend ITestableModule. You'll need to point flash to the com folder in order for this interface to be found.
- Remember that flash keeps signing with the last certificate you used. So when creating good and bad modules, and compiling the app itself, keep an eye on which certificate you're using.
- Module .air packages need to be renamed .zip
- You cannot test secure loading in the flash test player. You have to create the application .air file, install it and run it to test it.
- Don't forget to grab that SignatureUtils.swc from the Adobe link.
Addition: The flex source files are here.