The Messenger of Allah ﷺ said, "Do not sell fruit until its ripeness becomes apparent." He forbade both the seller and the buyer from doing so.
أخبرنا قتيبة قال حدثنا الليث عن نافع
عن رسول الله ﷺ قال لا تبيعوا الثمر حتى يبدو صلاحه نهى البائع والمشتري
[Its chain is sahih] Ibn Majah narrated it in "Trade," in the chapter on the prohibition of selling fruit before it shows signs of ripeness, hadith 2214, from the hadith of Layth bin Saad, with this wording. It is also in Kubra, hadith 6110, and it is agreed upon [by Bukhari and Muslim], from the hadith of Nafi from Ibn Umar, with this wording.