Hand-apply 20f9378678456f4c64f5d887e317a762faee6bde from master; fix calls to new digest() call.
Hand apply 4af669f559e1afd5375c8e96ee65f651aea0ec9f from master; give a nicer error when writing config fails.