Convex duality for stochastic shortest path problems in known and unknown environments