// Copyright 2021 The Gitea Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. package cmd import ( "crypto/tls" "net/http" "os" "strings" "code.gitea.io/gitea/modules/graceful" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" "github.com/klauspost/cpuid/v2" ) var tlsVersionStringMap = map[string]uint16{ "": tls.VersionTLS12, // Default to tls.VersionTLS12 "tlsv1.0": tls.VersionTLS10, "tlsv1.1": tls.VersionTLS11, "tlsv1.2": tls.VersionTLS12, "tlsv1.3": tls.VersionTLS13, } func toTLSVersion(version string) uint16 { tlsVersion, ok := tlsVersionStringMap[strings.TrimSpace(strings.ToLower(version))] if !ok { log.Warn("Unknown tls version: %s", version) return 0 } return tlsVersion } var curveStringMap = map[string]tls.CurveID{ "x25519": tls.X25519, "p256": tls.CurveP256, "p384": tls.CurveP384, "p521": tls.CurveP521, } func toCurvePreferences(preferences []string) []tls.CurveID { ids := make([]tls.CurveID, 0, len(preferences)) for _, pref := range preferences { id, ok := curveStringMap[strings.TrimSpace(strings.ToLower(pref))] if !ok { log.Warn("Unknown curve: %s", pref) } if id != 0 { ids = append(ids, id) } } return ids } var cipherStringMap = map[string]uint16{ "rsa_with_rc4_128_sha": tls.TLS_RSA_WITH_RC4_128_SHA, "rsa_with_3des_ede_cbc_sha": tls.TLS_RSA_WITH_3DES_EDE_CBC_SHA, "rsa_with_aes_128_cbc_sha": tls.TLS_RSA_WITH_AES_128_CBC_SHA, "rsa_with_aes_256_cbc_sha": tls.TLS_RSA_WITH_AES_256_CBC_SHA, "rsa_with_aes_128_cbc_sha256": tls.TLS_RSA_WITH_AES_128_CBC_SHA256, "rsa_with_aes_128_gcm_sha256": tls.TLS_RSA_WITH_AES_128_GCM_SHA256, "rsa_with_aes_256_gcm_sha384": tls.TLS_RSA_WITH_AES_256_GCM_SHA384, "ecdhe_ecdsa_with_rc4_128_sha": tls.TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, "ecdhe_ecdsa_with_aes_128_cbc_sha": tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, "ecdhe_ecdsa_with_aes_256_cbc_sha": tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, "ecdhe_rsa_with_rc4_128_sha": tls.TLS_ECDHE_RSA_WITH_RC4_128_SHA, "ecdhe_rsa_with_3des_ede_cbc_sha": tls.TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, "ecdhe_rsa_with_aes_128_cbc_sha": tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, "ecdhe_rsa_with_aes_256_cbc_sha": tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, "ecdhe_ecdsa_with_aes_128_cbc_sha256": tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, "ecdhe_rsa_with_aes_128_cbc_sha256": tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, "ecdhe_rsa_with_aes_128_gcm_sha256": tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, "ecdhe_ecdsa_with_aes_128_gcm_sha256": tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, "ecdhe_rsa_with_aes_256_gcm_sha384": tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, "ecdhe_ecdsa_with_aes_256_gcm_sha384": tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, "ecdhe_rsa_with_chacha20_poly1305_sha256": tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, "ecdhe_ecdsa_with_chacha20_poly1305_sha256": tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256, "ecdhe_rsa_with_chacha20_poly1305": tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305, "ecdhe_ecdsa_with_chacha20_poly1305": tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305, "aes_128_gcm_sha256": tls.TLS_AES_128_GCM_SHA256, "aes_256_gcm_sha384": tls.TLS_AES_256_GCM_SHA384, "chacha20_poly1305_sha256": tls.TLS_CHACHA20_POLY1305_SHA256, } func toTLSCiphers(cipherStrings []string) []uint16 { ciphers := make([]uint16, 0, len(cipherStrings)) for _, cipherString := range cipherStrings { cipher, ok := cipherStringMap[strings.TrimSpace(strings.ToLower(cipherString))] if !ok { log.Warn("Unknown cipher: %s", cipherString) } if cipher != 0 { ciphers = append(ciphers, cipher) } } return ciphers } // defaultCiphers uses hardware support to check if AES is specifically // supported by the CPU. // // If AES is supported AES ciphers will be preferred over ChaCha based ciphers // (This code is directly inspired by the certmagic code.) func defaultCiphers() []uint16 { if cpuid.CPU.Supports(cpuid.AESNI) { return defaultCiphersAESfirst } return defaultCiphersChaChaFirst } var ( defaultCiphersAES = []uint16{ tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, } defaultCiphersChaCha = []uint16{ tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305, tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305, } defaultCiphersAESfirst = append(defaultCiphersAES, defaultCiphersChaCha...) defaultCiphersChaChaFirst = append(defaultCiphersChaCha, defaultCiphersAES...) ) // runHTTPS listens on the provided network address and then calls // Serve to handle requests on incoming TLS connections. // // Filenames containing a certificate and matching private key for the server must // be provided. If the certificate is signed by a certificate authority, the // certFile should be the concatenation of the server's certificate followed by the // CA's certificate. func runHTTPS(network, listenAddr, name, certFile, keyFile string, m http.Handler, useProxyProtocol, proxyProtocolTLSBridging bool) error { tlsConfig := &tls.Config{} if tlsConfig.NextProtos == nil { tlsConfig.NextProtos = []string{"h2", "http/1.1"} } if version := toTLSVersion(setting.SSLMinimumVersion); version != 0 { tlsConfig.MinVersion = version } if version := toTLSVersion(setting.SSLMaximumVersion); version != 0 { tlsConfig.MaxVersion = version } // Set curve preferences tlsConfig.CurvePreferences = []tls.CurveID{ tls.X25519, tls.CurveP256, } if curves := toCurvePreferences(setting.SSLCurvePreferences); len(curves) > 0 { tlsConfig.CurvePreferences = curves } // Set cipher suites tlsConfig.CipherSuites = defaultCiphers() if ciphers := toTLSCiphers(setting.SSLCipherSuites); len(ciphers) > 0 { tlsConfig.CipherSuites = ciphers } tlsConfig.Certificates = make([]tls.Certificate, 1) certPEMBlock, err := os.ReadFile(certFile) if err != nil { log.Error("Failed to load https cert file %s for %s:%s: %v", certFile, network, listenAddr, err) return err } keyPEMBlock, err := os.ReadFile(keyFile) if err != nil { log.Error("Failed to load https key file %s for %s:%s: %v", keyFile, network, listenAddr, err) return err } tlsConfig.Certificates[0], err = tls.X509KeyPair(certPEMBlock, keyPEMBlock) if err != nil { log.Error("Failed to create certificate from cert file %s and key file %s for %s:%s: %v", certFile, keyFile, network, listenAddr, err) return err } return graceful.HTTPListenAndServeTLSConfig(network, listenAddr, name, tlsConfig, m, useProxyProtocol, proxyProtocolTLSBridging) } func runHTTPSWithTLSConfig(network, listenAddr, name string, tlsConfig *tls.Config, m http.Handler, useProxyProtocol, proxyProtocolTLSBridging bool) error { return graceful.HTTPListenAndServeTLSConfig(network, listenAddr, name, tlsConfig, m, useProxyProtocol, proxyProtocolTLSBridging) } s/archiva-web/archiva-webapp/src/main/archiva-web/qs-6.5.3 Apache Archiva Repository: https://github.com/apache/archivawww-data
summaryrefslogtreecommitdiffstats
path: root/archiva-cli/pom.xml
blob: 2201fdee4cbd8e6ae0f6328e273ed6ed0e98128e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?xml version="1.0"?>
<!--
  ~ Licensed to the Apache Software Foundation (ASF) under one
  ~ or more contributor license agreements.  See the NOTICE file
  ~ distributed with this work for additional information
  ~ regarding copyright ownership.  The ASF licenses this file
  ~ to you under the Apache License, Version 2.0 (the
  ~ "License"); you may not use this file except in compliance
  ~ with the License.  You may obtain a copy of the License at
  ~
  ~   http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing,
  ~ software distributed under the License is distributed on an
  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  ~ KIND, either express or implied.  See the License for the
  ~ specific language governing permissions and limitations
  ~ under the License.
  -->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <parent>
    <groupId>org.apache.archiva</groupId>
    <artifactId>archiva</artifactId>
    <version>2.2.8-SNAPSHOT</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>
  <artifactId>archiva-cli</artifactId>
  <name>Archiva :: Command Line Client</name>
  <dependencies>
    <dependency>
      <groupId>org.apache.archiva</groupId>
      <artifactId>archiva-repository-scanner</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.archiva</groupId>
      <artifactId>archiva-repository-admin-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.archiva</groupId>
      <artifactId>archiva-repository-admin-default</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.archiva</groupId>
      <artifactId>archiva-consumer-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.archiva</groupId>
      <artifactId>archiva-plexus-bridge</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.archiva</groupId>
      <artifactId>archiva-converter</artifactId>
      <exclusions>
        <exclusion>
          <groupId>commons-logging</groupId>
          <artifactId>commons-logging-api</artifactId>
        </exclusion>
        <exclusion>
          <groupId>log4j</groupId>
          <artifactId>log4j</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>com.google.code.cli-parser</groupId>
      <artifactId>cli</artifactId>
      <version>7</version>
    </dependency>
    <dependency>
      <groupId>commons-lang</groupId>
      <artifactId>commons-lang</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-slf4j-impl</artifactId>
    </dependency>
    <!-- Consumers to include -->
    <!--
    This will require some additional configuration now to point to an appropriate metadata repository storage, which is not in the CLI yet
    <dependency>
      <groupId>org.apache.archiva</groupId>
      <artifactId>archiva-metadata-consumer</artifactId>
      <scope>runtime</scope>
    </dependency>
    -->
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <finalName>apache-archiva-cli-${project.version}</finalName>
              <transformers>
                <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                  <resource>META-INF/spring.handlers</resource>
                </transformer>
                <transformer implementation="org.apache.maven.plugins.shade.resource.XmlAppendingTransformer">
                  <resource>META-INF/spring-context.xml</resource>
                </transformer>                
                <transformer implementation="org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer" />
              </transformers>
              <artifactSet>
                <excludes>
                  <exclude>xerces:xercesImpl</exclude>
                  <exclude>xml-apis:xml-apis</exclude>
                  <exclude>xalan:xalan</exclude>
                  <exclude>commons-beanutils:commons-beanutils</exclude>
                </excludes>
              </artifactSet>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <archive>
            <manifest>
              <mainClass>org.apache.archiva.cli.ArchivaCli</mainClass>
            </manifest>
          </archive>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <configuration>
          <executable>java</executable>
          <mainClass>org.apache.archiva.cli.ArchivaCli</mainClass>
          <arguments>
          </arguments>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>