Enforcing your rights under your contract by patching out some cert validation checks seems legal to me. Maybe not in places with anti-circumvention laws, but elsewhere it seems fine.