What you want is 3M Weatherstrip Adhesive. Comes in a red tube. You'd be hard pressed to find any mechanic who doesn't have a tube of it in his toolbox for holding gaskets, etc, in place. It holds so well, in the trade it's known as Yellow Death or Gorilla Snot.

It's made just for what you want to do.