Not sure if this idea is any good to you but my D-shackle goes under the rack. I raised the rack on aluminium pillars (tubing), inside which bolts pass from the top box, or rack surface, and fasten under the Yamaha tail plate.
The aluminium tube is from B+Q or any hardware store and is approx 8mm outside diameter and 6mm inside. The bolts I used were stainless M6 x 80mm and cut to length so the D-lock slid snugly under the rack.