That’s interesting that it says it’s forbidden to “sell” the relics but says nothing about buying them.
I suppose one could argue that buying the relic facilitates the sin of the seller. Also it would surely be wrong to go around offering people money proactively for a relic, for example, “Hey I’m willing to spend 5,000 dollars if you can just find me a relic of St. So-and-so.”
On the other hand, if a relic is on the market so it’s going to be sold anyway, and a Catholic felt they could give a particular relic a “good home”, it would seem to be okay to ransom the relic. If it were a first-class relic you would likely have to give it to a church but it would seem if it were a second or third class relic you could keep it.
There is a chapel in Pittsburgh (St. Anthony’s) with thousands of relics that were all bought by a wealthy, devout Catholic who went to Europe and bought them all during a time when Europe was in the throes of some kind of modernism or upheaval and everybody was getting rid of their relics, so he was able to get a lot of them for a good price. He ended up becoming a priest and building a chapel to house the whole collection of 5,000 relics. I realize he was operating under the older version of Canon Law though.