Is there a connection between St. Ambrose's "casta meretrix" and Apocalypse 17,1? The origins of the epithet "casta meretrix" are debated and not clear, do you know if anyone has ever related that to the words of John of Patmos "the great whore that sits on many waters" that many refer to the Roman Church?
Rahab a type for the Church
St. Ambrose uses the phrase &quot;casta meretrix&quot; in In Lucam III:23 (Patrologiae Latina XV, 1681):

Rahab illa typo meretrix (Josue, ii, 1), mysterio ecclesia indicavit: quae multorum convenarum publicæ non recusat, et quo conjunctior pluribus, castior; immaculata virgo, sine ruga, pudore integra, amore plebeia, casta meretrix, vidua sterilis, virgo fecunda. Meretrix, quia a pluribus amatoribus frequentatur cum dilectionis illecebra, et sine colluvione delicti: &quot;Qui,&quot; enim, &quot;adhæret meretrici, unum corpus est.&quot; (I Cor., vi, 16). Vidua sterilis, quæ viro parare non norit absente: venit vir, et hunc populum plebemque generavit. Virgo fecunda, quæ hanc genuit multitudinem cum fructu amoris, sine usu libidinis.

Rahab [Joshua 2:1] — who as a type was a prostitute, but as a mystery is the Church — showed in her blood the future sign of Universal Salvation amid the world’s carnage; she does not refuse to unite herself with numerous fugitives, and is all the more chaste in the extent to which she is closely joined to the greater number of them; she is the immaculate virgin, without a wrinkle, uncontaminated in her modesty, plebeian in her love, a chaste whore, a barren widow, a fecund virgin.* A whore because she frequents many lovers with the enticements of love: For &quot;he who is joined to a harlot is one body&quot; (1 Cor. 6:16). A barren widow who does not bear when her husband is absent; the husband coming, she gives birth to this people and nation. A fertile virgin who gives birth to this multitude with the fruit of love, without the use of lust.

*translation up to here from St. Ambrose scholar Cdl. Giacomo Biffi's Casta Meretrix: “The Chaste Whore,” An Essay on the Ecclesiology of St. Ambrose, as quoted in Br. André Marie's &quot;Is the Church a 'Harlot'?&quot;; what followers is my translation.
St. Ambrose's &quot;casta meretrix&quot; illustrates the sanctity of the Church and its necessity for salvation.
Br. André Marie's &quot;Is the Church a 'Harlot'?&quot; also includes the following quote from Casta Meretrix: “The Chaste Whore,” An Essay on the Ecclesiology of St. Ambrose, which shows that St. Ambrose was arguing for the doctrine that extra Ecclesiam nulla salus (outside the Church there is no salvation):

Ambrose says that she “as a type was a prostitute but as a mystery is
the Church, united now to the Gentiles by the sharing of the
sacraments.” …
The “typical” use of Rahab — a contradictory character, to whom was
attributed both an unworthy profession and a praiseworthy and
providential action — was already a classic in Christian literature.
Matthew’s Gospel has recalled her in the genealogy of Jesus (Matthew
1:5). The Letter to the Hebrews had featured her as an example of the
faith which saves (Hebrews 11:31). St. James, concerned with other
aspects of theology, had emphasised her justification obtained through
works, i.e., through the good deed that she did for the Hebrew scouts
(James 2:25). Clement of Rome, almost as though trying to synthesise
and reconcile the two texts, had written, “Through her faith and her
hospitality, Rahab the prostitute was saved” (I ad Corinthios 12:1).
After Clement, who dwells a long time on the episode of Joshua 2:1-21,
reading it in the light of the Redemption worked by Christ (cf. I ad
Corinthios 12:1-8), a definite ecclesiological interpretation of the
figure of Rahab is clearly delineated — from Justin to Irenaeus, to
Origen, to Cyprian. Indeed, it is through reflection upon the “house
of the prostitute” — the only house in Jericho which preserved its
occupants from death — that the famous principle emerged of extra
Ecclesiam nulla salus [outside the Church there is no salvation].
“No one could be deceived in this regard,” writes Origen, “no one
could be mistaken; outside of the house, that is to say outside of the
Church, there is no salvation.’ (Om. in Josue 3:4).
Cyprian in turn writes, “Do you think that you can live if you detach
yourself from the Church, building yourself other houses and different
dwelling places, when Rahab, prototype of the Church, was told that
anyone who left the door of her house would be guilty?” (De unitate
ecclesiae 8).
[In a footnote, His Eminence adds:] “In Cyprian, the principle of
“extra Ecclesiam nulla salus” is linked to the truth of the maternity
of the Church: “no one can have God for a father who does not have the
Church for a mother” (De unitate ecclesiae 6).

The Fathers do not interpret the whore of Apocalypse 17:1 as the Church.
As quoted in the Rheims English New Testament (PDF p. 586), (pseudo?-)Ambrose wrote:

This great whore sometime signifieth Rome, specially which at that time when the Apostle wrote this, did persecute the Church of God. But otherwise it signifieth the whole city of the Devil, that is, the universal corps of the reprobate.

Tertullian wrote (Liber adversus Iudaeos):

Babylon in St. John is a figure of the city of Rome, being so great, so proud of the Empire, and the destroyer of the saints.

Fr. Kramer's The Book of Destiny, the most recent in-depth exegesis on the book of the Apocalypse, commentates on Apocalypse 17:1:

A harlot is given to fornication. Ezechiel (XXIII.) calls Israel and Juda harlots, because they practiced the idolatry of the pagan nations bordering on Israel. Fornication and adultery in prophetical language mean apostasy from the true faith and from God. Hence this GREAT harlot is a city whose apostasy from the true faith is a monstrous thing. This may point to Rome. Rome is the Holy City of Christ, the center of His eternal kingdom, as Jerusalem was the center of the theocracy. And the apostasy of this city, and her becoming the head of an empire that would lead all possible nations and peoples into antichrist-worship would indeed merit for her the title of THE GREAT HARLOT. The apostles called ancient Rome &quot;Babylon&quot; (1 Peter V. 13). So the conclusion is near that the great harlot of the future shall be Rome. However, in this narration, St. John uses ancient pagan Rome as the model for his portrait of the Babylon of the future. And whichever city it shall be, it will obviously be one that was once entirely Catholic, apostatized from the true faith and became the capital of the kingdom that leads all nations into Antichrist-worship. Primasius says: &quot;meretricem vocans, quia relicto Creatore daemonibus se prostituit&quot; [calling it a harlot because it left the Creator and prostituted itself to demons]. (Swete, p. 213).

related: What is the Catholic interpretation of 2 Thessalonians 2:3 [that Antichrist &quot;sitteth in the temple of God&quot;]?