// We override the underlying method so that we can properly wrap incoming AHSenders override public PeerSecAssociation CreateSecurityAssociation(ISender sender, int spi) { PeerSecAssociation sa = null; lock (_sync) { sa = base.CreateSecurityAssociation(sender, spi); AHSender ahsender = sender as AHSender; if (ahsender != null) { Address target = ahsender.Destination; if (_address_to_sa.ContainsKey(target)) { sa = _address_to_sa[target] as PeerSecAssociation; } else { sa = base.CreateSecurityAssociation(sender, spi); _address_to_sa[target] = sa; _sa_to_address[sa] = target; } } } return(sa); }