[WIP] Feature/379 x509 lib to vendor

Fixes #379 

@relaxnow, I started this long ago, would you mind completing it (since you know more about the lib than I do and have more time)