Dear @EliOni,
Thank you for your question and for sharing your experience with us!
Here is an article dedicated to the issue on the Wefugees Blog (scroll down for English).
To sum it up, and to answer your question, in principle, you have the right to marry, whatever your legal status.
In practice, it can be difficult, especially for asylum seekers, due to the documents you need to submit to the Standesamt. These are:
- a valid passport, ID or certificate of citizenship (you should be able to get a certified copy of your passport from BAMF)
- a birth certificate
- and (in some cases) a certificate of no impediment from your country of origin (here the country you were born in); since it is not common in most countries, the Standesamt can make exceptions (so called "Befreiung von der Beibringung des ausländischen Ehefähigkeitszeugnis" - § 1309 Abs. 2 BGB).
I recommend you to get in touch with the Standesamt of the city you or your boyfriend live in as soon as possible to be sure to gather all the necessary documents (they might ask for more than the 3 I just cited).
Furthermore, since your asylum claim was rejected, the Ausländerbehörde might suspect you to marry for the only purpose of getting a residence permit (fictious marriage or "Scheinehe"). In such cases, they investigate to make sure this is not the case. Be prepared to cooperate in order to avoid any inconvenience.
I hope this answer and the blog article are helpful! Don't hesitate to add a comment if you need additional information.
All the best,
Safia