title: Using spring config server with git causing security group issue
body: <p>I am now trying to set up using spring config server / spring config client and eureka server to do service discovery together. when I was using local file system to save configuration, everything is fine, but as soon as I change to gitHub to save configuration, I can not start spring config client, and I got this error message:</p>
  
  <p>com.netflix.discovery.DiscoveryClient    : Can't get a response from <a href="http://user" rel="nofollow">http://user</a>:{cipher}AQBdTe9vjgOqANyfi+Ke5HYmhFJnuvsGJ+8FOqLgdMdFInJkVRzy9XngylNp9KlX2lwPI13jT7ceDjBs9w4B6A15akQTHHP1q9rWwMcLtVCCKGFgvXSgQF+WWIItxBmIDGG4bSgDYZ6XQWl66T84PxjTBygErpmAjn+X2BWdtWtVmjXzpMQMaHGpiyLPoGIQYF4j9ZGpl16Jx79+j6et6LStksrT3WxQuanhZwIkqZ827+2mlUB3kd5ocW7R0vC3JMGVZlGNfqYQwJIhSJ19lrq4gxm/zbGroYonW3QSHTiRlhlvOdovEua/0dCl6+s0iEHYZCBllr7jikEWmS5Px7U2TG8/eQkjR8pUbSN6OE+OI2ZZUCNOT+mi75ZeeN1OtdQ=@localhost:8761/eureka/null</p>
  
  <p>Can't contact any eureka nodes - possibly a security group issue?</p>
  
  <p>java.lang.IllegalArgumentException: Illegal character in authority at index 7: <a href="http://user" rel="nofollow">http://user</a>:{cipher}AQBdTe9vjgOqANyfi+Ke5HYmhFJnuvsGJ+8FOqLgdMdFInJkVRzy9XngylNp9KlX2lwPI13jT7ceDjBs9w4B6A15akQTHHP1q9rWwMcLtVCCKGFgvXSgQF+WWIItxBmIDGG4bSgDYZ6XQWl66T84PxjTBygErpmAjn+X2BWdtWtVmjXzpMQMaHGpiyLPoGIQYF4j9ZGpl16Jx79+j6et6LStksrT3WxQuanhZwIkqZ827+2mlUB3kd5ocW7R0vC3JMGVZlGNfqYQwJIhSJ19lrq4gxm/zbGroYonW3QSHTiRlhlvOdovEua/0dCl6+s0iEHYZCBllr7jikEWmS5Px7U2TG8/eQkjR8pUbSN6OE+OI2ZZUCNOT+mi75ZeeN1OtdQ=@localhost:8761/eureka/
      at java.net.URI.create(URI.java:852)</p>
  
  <p>This is what I have:</p>
  
  <ol>
  <li>In cofig server application.yml:</li>
  </ol>
  
  <blockquote>
  <pre><code> spring:
        application:
          name: spirent-config-server
        cloud:
          config:
            server:
              git:
                uri:  https://github.com/spring-cloud-samples/config-repo
                #searchPaths: foo,bar*
  
      server:
        port: 8888
  </code></pre>
  </blockquote>
  
  <ol start="2">
  <li>in config client:</li>
  </ol>
  
  <p>bootstrap.properties:</p>
  
  <blockquote>
  <pre><code>spring.application.name= foo
  spring.profiles.active= development
  spring.cloud.config.uri= http://localhost:8888
  </code></pre>
  </blockquote>
  
  <p>and application.yml</p>
  
  <pre><code>eureka:
    instance:
      hostname: ${host.instance.name:frank1}
      nonSecurePort: ${host.instance.port:8080}
      metadataMap:
        instanceId: ${host.instance.instanceid:frank_123}
    client:
      serviceUrl:
        defaultZone: http://localhost:8761/eureka/
  
  server:
    port: ${host.instance.port:8080}
  </code></pre>
  
  <ol start="3">
  <li>Eureka Server:</li>
  </ol>
  
  <p>application.yml</p>
  
  <pre><code>server:
    port: 8761
  
  eureka:
    client:
      registerWithEureka: false
      fetchRegistry: false
    server:
      waitTimeInMsWhenSyncEmpty: 0
  </code></pre>
  
  <p>bootstrap.yml:</p>
  
  <pre><code>spring:
    application:
      name: eureka
    cloud:
      config:
        uri: ${CONFIG_SERVER_URL:http://localhost:8888}
  </code></pre>
  
  <p>From the exception, it seemed it is because discoverClient is not working, anything special for the configuration?
  But if I change from gitHub to local file storage for configuration, everything is fine.</p>
  
  <p>Thanks for your suggestion in advance.</p>
  
  <p>Based on the spring cloud document, I am doing like this:</p>
  
  <p>In application.yml of config server:</p>
  
  <pre><code>spring:
    application:
      name: spirent-config-server
    cloud:
      config:
        server:
          git:
            uri:  https://github.com/spring-cloud-samples/config-repo
            #searchPaths: foo,bar*
  encrypt:
    key: abc
  
  server:
    port: 8888
  </code></pre>
  
  <p>In application.yml of Eureka Server:</p>
  
  <pre><code>server:
    port: 8761
  
  eureka:
    instance:
      hostname: localhost
    client:
      registerWithEureka: false
      fetchRegistry: false
      serviceUrl:
        defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
  
    server:
      waitTimeInMsWhenSyncEmpty: 0
  
  encrypt:
    key: abc
  </code></pre>
  
  <p>And in application.yml of config client:</p>
  
  <pre><code>eureka:
    instance:
      hostname: ${host.instance.name:frank1}
      nonSecurePort: ${host.instance.port:8080}
      leaseRenewalIntervalInSeconds: 5 #default is 30, recommended to keep default
      metadataMap:
        #instanceId: ${host.instance.instanceid:frank_123}
        instanceId: ${spring.application.name}:${spring.application.instance_id:${random.value}}
    client:
      serviceUrl:
        defaultZone: http://localhost:8761/eureka/
  
  server:
    port: ${host.instance.port:8080}
  
  encrypt:
    key: abc
  </code></pre>
  
  <p>But, the problem is after I started Eureka an config server, it is fine, no exception, but after I started config client, I got this same exception:</p>
  
  <pre><code>Can't contact any eureka nodes - possibly a security group issue?
  
  java.lang.IllegalArgumentException: Illegal character in authority at index 7: http://user:{cipher}AQBdTe9vjgOqANyfi+Ke5HYmhFJnuvsGJ+8FOqLgdMdFInJkVRzy9XngylNp9KlX2lwPI13jT7ceDjBs9w4B6A15akQTHHP1q9rWwMcLtVCCKGFgvXSgQF+WWIItxBmIDGG4bSgDYZ6XQWl66T84PxjTBygErpmAjn+X2BWdtWtVmjXzpMQMaHGpiyLPoGIQYF4j9ZGpl16Jx79+j6et6LStksrT3WxQuanhZwIkqZ827+2mlUB3kd5ocW7R0vC3JMGVZlGNfqYQwJIhSJ19lrq4gxm/zbGroYonW3QSHTiRlhlvOdovEua/0dCl6+s0iEHYZCBllr7jikEWmS5Px7U2TG8/eQkjR8pUbSN6OE+OI2ZZUCNOT+mi75ZeeN1OtdQ=@localhost:8761/eureka/
      at java.net.URI.create(URI.java:852)
      at com.sun.jersey.api.client.Client.resource(Client.java:433)
      at com.netflix.discovery.DiscoveryClient.makeRemoteCall(DiscoveryClient.java:1091)
      at com.netflix.discovery.DiscoveryClient.makeRemoteCall(DiscoveryClient.java:1060)
      at com.netflix.discovery.DiscoveryClient.getAndStoreFullRegistry(DiscoveryClient.java:835)
  </code></pre>
  
  <p>Can anyone tell me where is my error? This only happened in using GIT as config server data source, but in local file data source, no error happened.</p>
  
  <p>Thanks</p>
  
  <p>These are my steps to try to resolve the key issues, but failed again:</p>
  
  <ol>
  <li><p>download the "Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files" from Oracle, and follow instructions for installation (essentially replace the 2 policy files in the JRE lib/security directory with the ones that you downloaded). </p></li>
  <li><p>Now if I run spring encrypt mysecret --key foo, it is successful, this means the JCE is installed correctly;</p></li>
  <li><p>Creating a Key Store for Testing: using this:
  <a href="https://github.com/spring-cloud/spring-cloud-config/blob/master/docs/src/main/asciidoc/spring-cloud-config.adoc#creating-a-key-store-for-testing" rel="nofollow">https://github.com/spring-cloud/spring-cloud-config/blob/master/docs/src/main/asciidoc/spring-cloud-config.adoc#creating-a-key-store-for-testing</a></p></li>
  <li><p>after updating the application.yml in my config server, the  application.yml is this:</p></li>
  </ol>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>spring:
    application:
      name: spirent-config-server
    cloud:
      config:
        server:
          git:
            uri:  https://github.com/spring-cloud-samples/config-repo
            #searchPaths: foo,bar*
  encrypt:
    keyStore:
      location: classpath:/server.jks
      password: letmein
      alias: abc
      secret: changeme
    key: abc
  
  server:
    port: 8888</code></pre>
  </div>
  </div>
  </p>
  
  <ol start="5">
  <li><p>adding this to both eureka server and config client application.yml:</p>
  
  <p>encrypt:
    key: abc</p></li>
  <li><p>Run everything:
  Result is same nasty error</p></li>
  </ol>
  
  <p>So what is wrong is my testing? Thanks for your help</p>
  
  <p>It is my fault:
  Changing application.yml to this:</p>
  
  <pre><code>spring:
    application:
      name: configserver
  encrypt:
    failOnError: false
    keyStore:
      #location: classpath:keystore.jks
      #password: ${KEYSTORE_PASSWORD:foobar} # don't use a default in production
      #alias: test
      location: classpath:server.jks
      password: letmein
      alias: mytestkey
      secret: changeme
  </code></pre>
  
  <p>And then using this command to generate the file resolving the issue completely:</p>
  
  <p>keytool -genkeypair -alias mytestkey -keyalg RSA \
    -dname "CN=Web Server,OU=Unit,O=Organization,L=City,S=State,C=US" \
    -keypass changeme -keystore server.jks -storepass letmein</p>
  
  <p>Thanks </p>