If the sides are respectably flat around the point at which you want the connection, put a plate or 'giant washer' of paxolin / tufnol / suitable plastic between them, with 20 / 25 / 32mm hole in, and conduit bush and lockring / nut right through the lot. Screw one box to the wall firmly, leave the other free. Coat both sides of the plate with silicone, offer it and the other box up, snug up the conduit bush and then screw the second box to the wall. That will allow the conduit bush to clamp the sides of the boxes together without distorting them. The large area of silicone sealing the plate to each box will give you a reliable IP68.