Removing multiple lines but not the next attribute

I'm hitting a brick wall, I have huge ldif files that I'm trying to sanitize and can do it all with SED except one thing.

I have a publicKey attribute in binary that can be one line or multiple lines.
I'm trying to remove publicKey: and stop at sn (the next attribute). Even with word Wrap turned of it can span multiple lines.

I can figure out how to remove them both but not just the one when it is on multiple lines (2 to 4 lines).

I don't know if I explained it well enough, please let me know.

_______________________________

publickey:ahdkhafdhfasdahfdhhasdfdsfadfdaybutbsfdfklajdakjdafndnfkd;nfaksnaklsnfnfakfsldnan
sn:keepthisattribute

________________________________

Try..

$ cat file1
_______________________________

publickey:ahdkhafdhfasdahfdhhasdfdsfadfdaybutbsfdfklajdakjdafndnfkd;nfaksnaklsnfnfakfsldnan
sn:keepthisattribute

________________________________


$ awk '/^publickey:/{f=1}/^sn:/{f=0}!f' file1 > file2

$ cat file2
_______________________________

sn:keepthisattribute

________________________________


$

sed solution:

$ cat file1
publickey:ahdkhafdhfasdahfdhhasdfdsfadfdaybutbsfdfkl
ajdakjdafndnfkd;nfaksnaklsnfnfakfsldnan
sn:keepthisattribute
 
$ sed -n '/^publickey:/,/^sn:/{/^sn:/!b};p' file1
sn:keepthisattribute

Also, here are some solutions if publickey: and sn: don't always start at beginning of the line, eg:

before 
keyline publickey:ahdkhafdhfasdahfdhhasdfdsfadf
daybutbsfdfklajdak
jdafndnfkd;nfaksnaklsnfnfakfsldnansn:keepthisattribute and
the rest of
the doc

Awk solution:

awk '/publickey:/{j=1}j{o=o $0}/sn:/{sub(/publickey:.*sn:/,"sn:",o); $0=o; j=0} !j' infile

sed solution:

sed -n '/publickey:/!bo
:r
H;n
/sn:/!br
H;x
s/publickey:.*sn:/sn:/
s/^\n//
:o
p' infile

output:

before 
keyline sn:keepthisattribute and
the rest of
the doc

Ygor,
That worked perfectly and I was able to modify it when the publicKey migrated in the file today.
Chubler, I'm going to try your's tomorrow, got a file with one line....

Thank you both.