For a mains-supplied circuit I want to use an aluminium case, so the case can act as a heat sink. However, I want it to be safe, also when there's no earth connection in the socket where the circuit is plugged into.
What is the common way to make the circuit safe to use in an aluminium case?
I know that normally you would connect the earth-wire to the case, so in case one of the wires internally touches the case, the circuit breaker will turn off the power, protecting people from touching the enclosure while there is 230V on it (see also this question).
One way that might work is to use two diodes with the cathode connected to either of both mains wires and both anodes connected to the case. In case one of the mains wires accidentally touches the case the fuse would burn.
Any thoughts about this?
I don't think you can, legally or safely. The normal way round this is to move the mains-to-DC conversion into a power brick.
The other approach is "double insulation", which would require an insulated sub-enclosure inside the aluminium case.
The common way to make the circuit safe to use in a conductive case is to make the gadget DOUBLE INSULATED. EVERY part of the circuit MUST be abundantly ("double") insulated from the outside conductive enclosure. There must be NOTHING that the user can touch that is connected to the circuit in any way.
Of course, you have revealed nothing about what this circuit IS, so we don't know whether this is practical. If the circuit has input and/or output connections then this is impossible. You have also not disclosed WHY you are unable to use a proper grounded mains connection? Or whether you can use a GFCI/RCD as alternative safety measure.