Step 2 of 10 to earning a Canine Good Citizen title for your dog is the following:
"Sitting Politely for Petting. Goal: Evaluator pets dog. Dog must show no shyness or resentment."
If you did the training I suggested in Step 1, this one ought to be a breeze for you and your dog. To briefly recap, you want to first work with someone you know that can help by ignoring the dog if he jumps up or barks, growls, or hides behind you. By not looking at the dog and ignoring what he is doing, the other person is showing that unwanted behavior is not acceptable.
Once the dog obeys your "sit" command, then, the other person can speak to the dog, even pet him if the dog stays seated. Once the sit is broken, though, the helper needs to return to the ignoring stance.
Then, you've taken the dog to parks and other places where people are likely to be and asked some of them to help you teach your dog to sit quietly while you either speak briefly to the person, or the person is asked to pet the dog, so long as he will sit still. Explain to them before you permit them to pet the dog that you're trying to teach the dog to sit quietly for petting and if the dog jumps up, to please refrain from petting him at that time. It is rewarding unwanted behavior. Most people will have no problem with that.
Lastly, you want to teach the dog to be around children's playgrounds with all the quick-moving little bodies and shouting going on. This will also be useful in another phase of the title work, but for now, you're looking to find some children that will also listen to you when you ask them to pet your dog and to stop if he gets up from the sit. With children, though, I suggest you ask them to please pet the dog under the chin first.
Actually, that's an excellent way to approach any dog. Reaching for the head is perceived by the dog as a domination action and might result in problems. Reaching for the chin, however, is the greeting of an equal or subordinate. You've seen dogs lick another's chin, haven't you? By asking people to first scratch the dog's chin, then move to the head or back, you slowly let the newcomer dominate your dog rather than starting out that way.
It shouldn't take long for your dog to calm down enough on meeting people that he can easily pass the second test for the Canine Good Citizen title.
(The information in quotes at the beginning of this article is involved in the CGC test taken from the AKC test scoresheet.)