diff --git a/lib/SimpleSAML/Metadata/SAMLBuilder.php b/lib/SimpleSAML/Metadata/SAMLBuilder.php
index 1bf1568ea013ce3fa0297cd99915151a4d1ce4a5..400dbe06060110eb209d26184555c31a27585edc 100644
--- a/lib/SimpleSAML/Metadata/SAMLBuilder.php
+++ b/lib/SimpleSAML/Metadata/SAMLBuilder.php
@@ -139,6 +139,25 @@ class SimpleSAML_Metadata_SAMLBuilder {
 		}
 
 		$this->entityDescriptor->appendChild($e);
+		
+		if (array_key_exists('contacts', $metadata) && is_array($metadata['contacts']) ) {
+			foreach($metadata['contacts'] AS $contact) {
+				if (array_key_exists('contactType', $contact) && array_key_exists('EmailAddress', $contact)) {
+					$t = $this->createElement('ContactPerson');
+					$t->setAttribute('contactType', $contact['contactType']);
+					
+					if (array_key_exists('SurName', $contact)) {
+						$surname = $this->createTextElement('SurName', $contact['SurName']);
+						$t->appendChild($surname);
+					}
+					
+					$email = $this->createTextElement('EmailAddress', $contact['EmailAddress']);
+					$t->appendChild($email);
+					
+					$this->entityDescriptor->appendChild($t);
+				}
+			}
+		}
 	}
 
 
@@ -183,8 +202,28 @@ class SimpleSAML_Metadata_SAMLBuilder {
 			$t->setAttribute('Location', $metadata['SingleSignOnService']);
 			$e->appendChild($t);
 		}
-
+		
 		$this->entityDescriptor->appendChild($e);
+		
+		if (array_key_exists('contacts', $metadata) && is_array($metadata['contacts']) ) {
+			foreach($metadata['contacts'] AS $contact) {
+				if (array_key_exists('contactType', $contact) && array_key_exists('EmailAddress', $contact)) {
+					$t = $this->createElement('ContactPerson');
+					$t->setAttribute('contactType', $contact['contactType']);
+					
+					if (array_key_exists('SurName', $contact)) {
+						$surname = $this->createTextElement('SurName', $contact['SurName']);
+						$t->appendChild($surname);
+					}
+					
+					$email = $this->createTextElement('EmailAddress', $contact['EmailAddress']);
+					$t->appendChild($email);
+					
+					$this->entityDescriptor->appendChild($t);
+				}
+			}
+		}
+
 	}