A variational approach to Ising spin glasses in finite dimensions